details212
asked on
Batch file to remove character in file name
need a batch file to loop through a bunch or jpg in a folder and remove ! and # and " " ,<-- that's a space in the file names
Many thanks
Many thanks
This should do the trick:
Add another "echo" to see what it will do without actually executing the renames:
for %a in (*) do @for /F "tokens=1,2,3,4,5,6,7,8,9* delims=#! " %i in ("%a") do ren "%a" "%i%j%k%l%m%n%o%p%q%r"
Add another "echo" to see what it will do without actually executing the renames:
c:\temp\foo>for %a in (*) do @for /F "tokens=1,2,3,4,5,6,7,8,9* delims=#! " %i in ("%a") do @echo ren "%a" "%i%j%k%l%m%n%o%p%q%r"
ren "a!b" "ab"
ren "a!b .txt" "ab.txt"
ren "e!f#g h.txt" "efgh.txt"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Wow, awsome
I can't see this working in DOS nor CMD... Unless of course, powershell does what DOS does not...
As billprew says, the exclamation mark is a problem...
Here's a quick test:
COPY NUL "file!! ##.jpg"
Sure, you can see the file with a DIR command... You can also rename the file ie,
REN "file!! ##.jpg" file.jpg
What you can't do though is this:
FOR %%a IN (*.jpg) DO ECHO %%a
It will show %%a as:
file ##.jpg
instead of:
file!! ##.jpg
Please confirm if this is not the case.
As billprew says, the exclamation mark is a problem...
Here's a quick test:
COPY NUL "file!! ##.jpg"
Sure, you can see the file with a DIR command... You can also rename the file ie,
REN "file!! ##.jpg" file.jpg
What you can't do though is this:
FOR %%a IN (*.jpg) DO ECHO %%a
It will show %%a as:
file ##.jpg
instead of:
file!! ##.jpg
Please confirm if this is not the case.
Works for me. Did you even try it? What makes you think the exclamation point is special?
c:\temp\foo>echo foo >a!b.jpg
c:\temp\foo>for %a in (*.jpg) do echo %a
c:\temp\foo>echo a!b.jpg
a!b.jpg
c:\temp\foo>
ASKER
worked fine for me in win7 cmd
http://www.den4b.com/?x=products&product=renamer
http://www.bulkrenameutility.co.uk/Main_Intro.php
~bp