BATCH : Change special characters from filenames (é è à…)

[From]: http://stackoverflow.com/questions/18234894/batch-change-special-characters-from-filenames-%C3%A9-%C3%A8-%C3%A0

Batch can properly manage any Ascii character, that is, characters with code below or equal 255. This is obvious, because the Batch code itself must also be written in Ascii.

@echo off
set remove=áéíóúÜü
set string=Aaá Eeé Iií Ooó UuÜüú It Works!
for /F "tokens=1-26 delims=%remove%" %%a in ("%string%") do (
   set newString=%%a%%b%%c%%d%%e%%f%%g%%h%%i%%j%%k%%l%%m%%n%%o%%p%%q%%r%%s%%t%%u%%v%%w%%x%%y%%z
)
echo "%newString%"

Output:

"Aa Ee Ii Oo Uu It Works!"

If the characters you want to remove are not Ascii (codes above 255), then a Batch program can not solve this problem.

shareedit
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s