Skip navigation.
 
mlRe: Renaming files?
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

Related mailsAuthorDate
mlRenaming files? Christoffer Lerno Dec 20, 18:01
mlRe: Renaming files? Clark Cox Dec 20, 20:10
mlRe: Renaming files? Jeremy Dronfield Dec 20, 23:11
mlRe: Renaming files? Brendan Younger Dec 20, 23:29
mlRe: Renaming files? Andrew Farmer Dec 21, 00:04
mlRe: Renaming files? Christoffer Lerno Dec 21, 12:20
mlRe: Renaming files? Clark Cox Dec 21, 15:27
mlRe: Renaming files? Christoffer Lerno Dec 22, 10:41
mlRe: Renaming files? Christoffer Lerno Dec 22, 10:56
mlRe: Renaming files? Jeremy Dronfield Dec 22, 15:03
mlRe: Renaming files? Clark Cox Dec 22, 17:30
mlRe: Renaming files? Clark Cox Dec 22, 17:35
mlRe: Renaming files? Jeremy Dronfield Dec 22, 18:54
mlRe: Renaming files? Christoffer Lerno Dec 22, 20:03
mlRe: Renaming files? Christoffer Lerno Dec 22, 20:10
mlRe: Renaming files? Clark Cox Dec 22, 20:30
mlRe: Renaming files? Andreas Mayer Dec 22, 20:35
mlRe: Renaming files? Clark Cox Dec 22, 21:04
mlRe: Renaming files? Christoffer Lerno Dec 23, 10:53