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


Groups > comp.lang.python > #3747

RE: renaming files in OS X

Date 2011-04-20 20:06 +0000
From <jyoung79@kc.rr.com>
Subject RE: renaming files in OS X
Newsgroups comp.lang.python
Message-ID <mailman.670.1303329973.9059.python-list@python.org> (permalink)

Show all headers | 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