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


Groups > comp.lang.python > #3731

Re: renaming files in OS X

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <philip@semanchuk.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.054
X-Spam-Evidence '*H*': 0.89; '*S*': 0.00; 'though.': 0.07; 'attributes,': 0.09; 'subject:files': 0.09; 'to:name:python list': 0.09; 'written': 0.12; 'am,': 0.14; 'wrote:': 0.14; 'out?': 0.16; 'python;': 0.16; 'shutil': 0.16; "he's": 0.19; 'command': 0.19; 'header:In-Reply-To:1': 0.22; 'referring': 0.23; "i'm": 0.26; "doesn't": 0.28; 'about.': 0.29; 'least': 0.30; 'use?': 0.31; 'does': 0.31; 'however,': 0.31; 'to:addr:python-list': 0.32; "i've": 0.33; 'someone': 0.33; 'test': 0.33; 'using': 0.34; 'received:172.16': 0.35; 'file': 0.35; 'surely': 0.35; 'hello,': 0.36; 'think': 0.36; 'shows': 0.36; 'useful': 0.37; '20,': 0.38; 'apr': 0.38; 'but': 0.38; 'files': 0.38; 'to:addr:python.org': 0.39; 'header:Mime-Version:1': 0.39; 'might': 0.40; 'philip': 0.60; 'simple': 0.60; 'charset:windows-1252': 0.61; 'header :Message-Id:1': 0.62; 'extended': 0.64; 'lives': 0.64; 'safe': 0.65; 'want,': 0.72; '(snow': 0.84; 'empirical': 0.84; 'metadata': 0.84
Subject Re: renaming files in OS X
Mime-Version 1.0 (Apple Message framework v1084)
Content-Type text/plain; charset=windows-1252
From Philip Semanchuk <philip@semanchuk.com>
X-Priority 3 (Normal)
In-Reply-To <20110420140240.534UB.124867.root@cdptpa-web13-z01>
Date Wed, 20 Apr 2011 11:35:29 -0400
Content-Transfer-Encoding quoted-printable
References <20110420140240.534UB.124867.root@cdptpa-web13-z01>
To Python list <python-list@python.org>
X-Mailer Apple Mail (2.1084)
X-Scanned-By MIMEDefang 2.67 on 152.16.195.41
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.657.1303320318.9059.python-list@python.org> (permalink)
Lines 31
NNTP-Posting-Host 82.94.164.166
X-Trace 1303320319 news.xs4all.nl 41103 [::ffff:82.94.164.166]:53890
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:3731

Show key headers only | 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 | Unroll thread


Thread

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

csiph-web