Solved Batch file to rename multiple file

March 11, 2013 at 07:00:58
Specs: Windows XP
Have been looking for a batch file to rename multiple files in a folder.
here is a example;
6443100-Strogatz-Sh-Nonlinear-Dynamics-and-Chaos-1994.pdf
to
Nonlinear Dynamics and Chaos by Strogatz Sh 1994.pdf

or
5013722-Lab-Manual-for-Applied-Botany.pdf
to
Lab Manual for Applied Botany.pdf

have found loads of information, but my knowledge is to small to make a proper batch file for this task.
wish to input directory before beginning,
asked if suggested filename change is good
and if not give proper suggestion.

anyone up for the task to learn me how to do this?


See More: Batch file to rename multiple file

Report •


#1
March 11, 2013 at 17:51:07
✔ Best Answer
I can't get too fancy on a fixed time-budget, so this gives you 'bout all i got:
::==== begin batch lorcan.bat
@echo off & setlocal
set /p dir=directory to process:
pushd %dir%
for /f "tokens=1* delims=-" %%a in ('dir /b *-*.pdf') do (
set file=%%~nb.pdf
call :xx %%~nb
)
popd
goto :eof

:xx
set outp=%1
set outp=%outp:-= %
echo %outp%
set k=n
set /p k=swap items 1,2 to end (author-swap)? y/n:
call :%k% %outp%
goto :eof

:y
set e=%1 %2
for /f "tokens=2*" %%a in ("%*") do set outp=%%b %1 %2

:n
echo ADDING LINE TO NEWNAME.BAT:ren %file% %outp%.pdf
>>newname.bat echo ren %file% %outp%.pdf
::====== end batch
sent the "renames" to the batchfile so you have more control, and can still go in and change things that look wrong. The batchfile "newname" will be in the target/working directory.


Report •
Related Solutions


Ask Question