Re: Renaming files?
Re: Renaming files?
- Subject: Re: Renaming files?
- From: Jeremy Dronfield <email@hidden>
- Date: Mon, 20 Dec 2004 22:11:46 +0000
On 20 Dec 2004, at 5:01 pm, Christoffer Lerno wrote:
I thought I had renaming files nailed down by using NSFileManager's
movePath:toPath:handler: but it has problems with spaces & non ascii
characters in filenames - the documentation unfortunately doesn't
reveal how this is circumvented.
In my experience, the only character -movePath:toPath:handler: can't
cope with is a "/". It's possible, using the Finder, to put a slash in
a filename, and NSFileManager interprets it as a path separator. (There
may even be a way round this, but I haven't looked. I know Carbon can
cope with it.)
If you're having trouble with spaces, I think there's something going
wrong with the way you're feeding pathnames to NSFileManager. I just
tried it with files called:
“!”•¶ ^^ é @£## {€} %\<> .gif
©∆ Ø∏ ‡ ‰üœÚ ¬ ƒ© ≠ª .tiff
which I renamed as
new0001.gif
new0002.tiff
using -[NSFileManager movePath:toPath:handler:] No problem. To test it
back the other way, I renamed "new0002.tiff" as "U î Ü © #€
{˚}0002.tiff". Again no problem.
I mostly use NSWorkspace and NSWorkspace is a lot better at dealing
with sort of things. Unfortunately it seems that rename is missing
from NSWorkspace.
NSWorkspace isn't really intended for that kind of low-level file
management operation.
So what are my options aside from working with FSRenameUnicode and
such?
Use -[NSFileManager movePath:toPath:handler:]. It's perfectly capable
of doing what you want.
Regards,
Jeremy
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden