Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #3747

RE: renaming files in OS X

Path csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <jyoung79@kc.rr.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.055
X-Spam-Evidence '*H*': 0.89; '*S*': 0.00; 'wrapper': 0.07; 'attribute': 0.09; 'attributes,': 0.09; 'rename': 0.09; 'subject:files': 0.09; 'am,': 0.14; 'wrote:': 0.14; 'preserved': 0.16; 'renames': 0.16; 'semanchuk': 0.16; 'shutil': 0.16; 'case.': 0.16; 'command': 0.19; 'handles': 0.20; "didn't": 0.25; 'version': 0.25; "i'm": 0.26; 'thanks': 0.29; 'received:75': 0.30; 'does': 0.31; 'to:addr:python-list': 0.32; 'thank': 0.32; 'copying': 0.34; 'using': 0.34; 'there': 0.35; 'file': 0.35; 'received:rr.com': 0.35; 'received:mail.rr.com': 0.35; 'none': 0.36; 'shows': 0.36; 'system.': 0.37; 'exactly': 0.37; '20,': 0.38; 'apr': 0.38; 'files': 0.38; 'realize': 0.39; 'to:addr:python.org': 0.39; 'works': 0.40; "it's": 0.40; 'philip': 0.60; 'simple': 0.60; 'from:no real name:2**0': 0.60; 'taking': 0.61; 'extended': 0.64; 'share': 0.67; 'article': 0.75; '(snow': 0.84; '16:30': 0.84; 'jay': 0.84; 'metadata': 0.84; 'well:': 0.84
Authentication-Results cdptpa-omtalb.mail.rr.com smtp.user=jyoung79@kc.rr.com; auth=pass (LOGIN)
X-Authority-Analysis v=1.1 cv=2vPzMgfOIErJN3e9oB0C+rg2PyH4jEtKOmutOqWodeY= c=1 sm=0 a=vYBo3EzpB60A:10 a=IkcTkHD0fZMA:10 a=-w5ALONIAAAA:8 a=ayC55rCoAAAA:8 a=LinV0nLEinDzxsnnAbwA:9 a=rP6CjnBQ4CdaP2qVpCAA:7 a=QEXdDO2ut3YA:10 a=tX5XewDJAJsA:10 a=rP986PgBVUNmvCLcgKrpog==:117
X-Cloudmark-Score 0
Date Wed, 20 Apr 2011 20:06:11 +0000
From <jyoung79@kc.rr.com>
To python-list@python.org
Subject RE: renaming files in OS X
MIME-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding quoted-printable
X-Priority 3 (Normal)
Sensitivity Normal
X-Originating-IP
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.670.1303329973.9059.python-list@python.org> (permalink)
Lines 38
NNTP-Posting-Host 82.94.164.166
X-Trace 1303329973 news.xs4all.nl 81483 [::ffff:82.94.164.166]:55683
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:3747

Show key headers only | View raw


> In article <280CB56A-89B8-4D62-9374-D769B3ACFEBB at semanchuk.com>,
>  Philip Semanchuk <philip at semanchuk.com> wrote:
> > On Apr 20, 2011, at 10:02 AM, <jyoung79 at kc.rr.com> <jyoung79 at kc.rr.com> 
> > wrote:
> > > I'm considering using os.rename or shutil for renaming 
> > > files on OS X (Snow Leopard)…

> os.rename() is a simple wrapper around the standard rename system call 
> (man 2 rename) so it has the same semantics.  Extended attributes, 
> including resource forks, are preserved by rename(2).  Note that the 
> system call only works for renames within one file system.  The mv(1) 
> program handles cross-system renames by copying and unlinking and the 
> Apple-supplied version does copy extended attribute metadata in that 
> case.  As documented, none of the shutil copy functions do that.

> > The OS X command xattr  shows whether or not a file has extended attributes, 

> The 'ls -l' command does as well:

> $ ls -l a.jpg
> -rw-r--r--@  1 nad  staff  2425268 Apr  4 16:30 a.jpg
> $ ls -l@ a.jpg
> -rw-r--r--@  1 nad  staff  2425268 Apr  4 16:30 a.jpg
>    com.apple.FinderInfo      32


Hi Ned,

Thanks so much for this detail!  I didn't even realize there was a standard
rename system call - it's always nice learning something new about this
system.

Again, thank you for taking the time to share your knowledge.  This is
exactly what I was looking for!

Jay

Back to comp.lang.python | Previous | Next | Find similar


Thread

RE: renaming files in OS X <jyoung79@kc.rr.com> - 2011-04-20 20:06 +0000

csiph-web