FROM : Jeremy Dronfield
DATE : Mon Dec 20 23:11:46 2004
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
DATE : Mon Dec 20 23:11:46 2004
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
| Related mails | Author | Date |
|---|---|---|
| Christoffer Lerno | Dec 20, 18:01 | |
| Clark Cox | Dec 20, 20:10 | |
| Jeremy Dronfield | Dec 20, 23:11 | |
| Brendan Younger | Dec 20, 23:29 | |
| Andrew Farmer | Dec 21, 00:04 | |
| Christoffer Lerno | Dec 21, 12:20 | |
| Clark Cox | Dec 21, 15:27 | |
| Christoffer Lerno | Dec 22, 10:41 | |
| Christoffer Lerno | Dec 22, 10:56 | |
| Jeremy Dronfield | Dec 22, 15:03 | |
| Clark Cox | Dec 22, 17:30 | |
| Clark Cox | Dec 22, 17:35 | |
| Jeremy Dronfield | Dec 22, 18:54 | |
| Christoffer Lerno | Dec 22, 20:03 | |
| Christoffer Lerno | Dec 22, 20:10 | |
| Clark Cox | Dec 22, 20:30 | |
| Andreas Mayer | Dec 22, 20:35 | |
| Clark Cox | Dec 22, 21:04 | |
| Christoffer Lerno | Dec 23, 10:53 |






Cocoa mail archive

