Remove space from filenames

Closed
logic - 22 Apr 2010 à 19:43
closeup22 Posts 8922 Registration date Friday 15 May 2009 Status Member Last seen 7 October 2010 - 23 Apr 2010 à 06:01
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 8922 Registration date Friday 15 May 2009 Status Member Last seen 7 October 2010 2,099
23 Apr 2010 à 06:01
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