renaming files in OS X

jyoung79 at kc.rr.com jyoung79 at kc.rr.com
Wed Apr 20 21:00:56 CEST 2011


>> I'm considering using os.rename or shutil for renaming 
>> files on OS X (Snow Leopard)...

> 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


Hi Philip,

Thank you very much for your reply.  This actually does 
help a lot!  I had done a bit of testing earlier, but
I admit I'm quite ignorant on Apples file structure.
Your excellent link had some great info and I did a
few tests with what it had to say before and after I
ran os.rename on a file.  I also ran some applescript
code to get the file/creator type before and after
os.name (although I don't believe these types are
actually part of the resource fork, they're still used
by some scripts we run).  So far, after running
os.name, the file still contains everything I can think
of so far.

Again, thank you for your help with this!

Jay



More information about the Python-list mailing list