Needing to rename a bunch of files on a win32 system, I thought I’d try to bang together a perl one-liner. Two challenges:
- you can’t use a double-quote character on the command-line, because the eval-ed text is delimited with double quotes, and
- I had to include a double-quote character in the executed command because the filenames contained spaces.
My creation:
C:\Temp\test>dir /b | perl -ne "$q=chr(34); chomp; $on=$_; s/Strip this part //; $cmd=sprintf qq{ren %s %s}, $q.$on.$q,$q.$_.$q; print qx{$cmd};"
And away we go.