Wednesday, October 5, 2011

Deletes %20 in file names batch script

Reference: http://www.computing.net/answers/programming/batch-remove-20-from-filenames/13957.html

Hi there, this is a batch script that automatically deletes those %20 in file names. And it replaces those "%20"s with "spaces". It is for those files you downloaded from websites, but came out with ugly file names. The script came from the reference link posted by shahramsh. I am not exactly sure how some parts of the script works, for example the "for" loop. However, just put the batch file in the same directory as the files with the %20. I've made some amendments to shahramsh's script at line 3 and line 5. I have added an extra % in line 3. Additionally, I have added " " in line 5 so that it will replace every %20 with a space instead of blank.


Warning: Use at own risk


The script:


@echo off
setlocal EnableDelayedExpansion
for /f "delims=" %%I in ('dir /b ^| find "%%20"') do (
set var01=%%I
set var02=!var01:%%20=" "!
call :ren
)
:ren
ren %var01% %var02%


Instructions:

1. Copy the script above and paste into notepad

2. Save it as "spaceReplacer.bat", file type: All Type.

3. Put it in the same folder as the files with %20 and run



0 comments, add yours>>: