M
Michael Wojcik
<OT> With a few mingw tools and line breaks added for posting:
dir %1 /b | tr -d "\r" |
gawk >renames.bat "-vq=\"" -vr=rename
"{x=$0;sub(/%2/,\"%3\");print r,q x q,q $0 q}"
and then do 'renames'.
[OT]
Under XP, with Command Extensions enabled[1]:
for %a in ("* *") do (
for /f "tokens=1,*" %b in ('echo %a') do ren "%a" "%b%c"
)
will remove the first space from any filename containing at least one
space in the current directory. (The outer for selects files with at
least one space in their names; the inner for parses the names into
prefix and suffix, delimited by the first space, and renames them
with that first space removed.)
Personally, I have and in most cases prefer the Unix utilities, but
for people who don't have or know them, cmd.exe will generally do
this sort of thing, once you master its arcane syntax and odd corner
cases.
[1] Command Extensions is an option for cmd.exe which can be enabled
by setting some Registry key. It's documented in all of the usual
places. It should be enabled; it makes cmd.exe moderately useful.