Remove space from filenames

Closed
logic - Apr 22, 2010 at 07:43 PM
closeup22 Posts 8923 Registration date Friday May 15, 2009 Status Member Last seen October 7, 2010 - Apr 23, 2010 at 06:01 AM
hi i have this script that i got from a website but im wondering if its possible to also have it remove spaces from files inside sub directories? can anyone help me with code to remove spaces from pdf files inside subdirectories also.

i added the switch /s after dir but it gave me a syntax error.

please help.

i need it to remove all spaces from filenames and remove spaces from filenames in subdirectories as well . but leave the subdirectories with spaces, only remove spaces from pdf fie names.

thank you for your help. in advance

-JC

@echo off
dir /b /a-d *.* > c:\temp.txt
for /F "tokens=*" %%* in (c:\temp.txt) do call :sub %%*
del c:\temp.txt
goto :eof

:sub
ren "%*" %1%2%3%4%5%6%7%8%9
Related:

1 response

closeup22 Posts 8923 Registration date Friday May 15, 2009 Status Member Last seen October 7, 2010 2,099
Apr 23, 2010 at 06:01 AM
Hi there,

You can make a try with it ,before proceeding make a backup and create a restore point in case all goes wrong.

Thanks
0