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


Groups > comp.lang.python > #3731

Re: renaming files in OS X

Subject Re: renaming files in OS X
From Philip Semanchuk <philip@semanchuk.com>
Date 2011-04-20 11:35 -0400
References <20110420140240.534UB.124867.root@cdptpa-web13-z01>
Newsgroups comp.lang.python
Message-ID <mailman.657.1303320318.9059.python-list@python.org> (permalink)

Show all headers | View raw


On Apr 20, 2011, at 10:02 AM, <jyoung79@kc.rr.com> <jyoung79@kc.rr.com> wrote:

> Hello,
> 
> I'm considering using os.rename or shutil for renaming 
> files on OS X (Snow Leopard).  However, I've read that 
> shutil doesn't copy the resource fork or metadata for 
> the files on OS X.  I'm not sure about os.rename though.  
> I need to keep the resource fork and metadata.  Is it 
> better if I just use os.system('mv …') or is os.rename 
> safe to use?

Hi Jay,
I don't know if os.rename() does what you want, but why don't you try a simple test and find out? Surely an empirical test is at least as useful as an answer from someone like me who may or may not know what he's talking about. =)

The OS X command xattr  shows whether or not a file has extended attributes, which are what I think you're referring to when you say "metadata". xattr is written (badly) in Python; on my system it lives in /usr/bin/xattr-2.6

You might also find this helpful:
http://jonsview.com/mac-os-x-resource-forks


Hope this helps
Philip

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


Thread

Re: renaming files in OS X Philip Semanchuk <philip@semanchuk.com> - 2011-04-20 11:35 -0400

csiph-web