Simple Batch File Renaming Script

January 2, 2011 at 19:42:20
Specs: Windows 7
Hello Everyone! I have over a thousand txt files that need renaming. Normally I would do this myself but I cant figure out how to make a batch file that will replace a .dot with a whitespace.

They are all named like this...

name.sourceProgram.subSourceProgram.dateCreated.timeCreated.txt (the amount of dots sometimes varies)

Im still learning in C++, but I dont know any windows/batch scripting language. What I need is a simple batch/script file that can replace the .dot's with a whitespace then put .txt at the end of the files.

Thanks!
Paul


P.S. Sorry about the repost


See More: Simple Batch File Renaming Script

Report •

#1
January 2, 2011 at 19:51:19
Place this where the text file are located:

@ECHO OFF
SETLOCAL EnableDelayedExpansion

FOR /f "tokens=*" %%a IN ('DIR /b "*.txt"') DO (
SET Var=%%~na
SET Var=!Var:.= !
REN "%%a" "!Var!.txt"
)

Can I put a question here?


Report •

#2
January 2, 2011 at 19:59:05
Awesome! your the best!

Report •

#3
January 2, 2011 at 20:09:23
=) Thanks, glad it worked.

Can I put a question here?


Report •
Related Solutions


Ask Question