I’ve got about fifteen files with %20 in the filename that I want to rename, ideally to replace the %20 with an actual space. (This is on Windows XP.) I’ve found previous threads on the subject of batch renaming where various utilities were recommended, but I’ve been trying to do this using the Windows rename command in a simple batch file. But Windows XP seemed to ignore the %20 when I created a batch file like this:
Thank you, but as I said, this is more about trying to figure this out. I’ve already spent more time trying to do it in a batch file than it would take to do it manually, but I find this sort of thing interesting.
I can’t test this at the moment I’m guessing you need to escape some of the characters but try changing to the directory the files are in and starting off typing
ren file
and hit tab, it should complete the file name and properly escape the chars. Then fill in the rest of the command.
You can then either copy the format windows used or repeat the process (hiting tab multiple times cycles through the matching filenames).
It should be possible from the command line. My only other option is that it doesn’t like the file names (because at some level they’re equivalent). So you could try changing to an intermediate filename and then renaming that, I’ve used that in the past when windows acts up.
The reason it didn’t work is because the command interpreter recognizes the percent symbol as the beginning of a variable and tries to match it to the variable table.
When you type ‘set’ at the command prompt you’ll get a list of set variables, heres a cut from mine:
So if I typed ‘dir %SystemRoot%’, it would give me a directory listing of ‘C:\WINNT’, because %SystemRoot% is a variable matched to ‘C:\WINNT’. Just in case you didn’t know.
As you find this sort of thing interesting, you may find cygwin interesting. It’s not a file-renaming utility. Rather, it’s like having a unix command prompt on a pc. (technically, it’s the bash shell on Windows.) If you like doing things at the command line (as do I as well), and you like making batch files to solve these sorts of problems, I highly recommend you check it out.
I’ll second Cygwin. Moving from DOS BATCH to bash is like going from a Yugo to a Corvette, and if you have any inclinations of learning another language bash shares the same basic structure as 90% of all modern language.
Does Cygwin include any POSIX libraries, or is it merely the shell and the GNU command-line utilities? It’s been years since I used it to work around the bug that is Windows 95.