in reply to Renaming files in dir

If you're not moving the file between disks, there's no need to use a module. The built in rename will work just fine.

And I suspect your problems could be related that you don't give a full path for both arguments of move, but to just one. Maybe, instead of prepending "$path/" in front of the file name everywhere, you could chdir to $path first, and then you can use relative paths, i.e. just use the bare file basename.

A possible second reason for trouble is that the characters you're trying to change are not in Ascii. Under the hood, (western) Windows uses 2 character sets: CP1252, Microsoft's extension to Latin-1, for the GUI, and an old DOS compatible code page (4 hundred something?) for the console — and maybe for the filesystem, too. Just try to run a script like

print "ä\n";
in the console, and you'll see what I mean. If that is indeed a problem, you'll have to find out the character code of the characters you're trying to change.

Replies are listed 'Best First'.
Re^2: Renaming files in dir
by larus (Acolyte) on Mar 19, 2009 at 08:57 UTC
    Thanks, scandinavian characters are not the problem, the code I posted produces right substitutions. The problem is that I don't know how to save (replace) those files in the same directory with the new (chars substituted) names.
      The problem is that I don't know how to save (replace) those files in the same directory with the new (chars substituted) names.
      Like I said: use the full path for both arguments (old and new name) for move/rename, or chdir to that directory first, and use just the bare filename.