Monday, October 13, 2008

How to rename every file in a directory from a command prompt

Found this on another site (forgot where) Just in case I need this in the future

Create a .bat file and paste in

for %%f in (_*.*) do call :renamer %%f
goto :eof

:renamer
set old=%1
echo %1
ren %1 %old:~1,9%
:: end

in line 1 the _ is the character pattern to match
on line 6 change ~1 to the number of characters from line 1

No comments: