Solved Batch file to rename pdf 012567890345 to 01_256_78_9_0345

August 27, 2014 at 07:31:34
Specs: Windows 7
Hi, I am search batch program which will change the multiple pdf file from 012567890345 to 01_256_78_9_0345.

See More: Batch file to rename pdf 012567890345 to 01_256_78_9_0345

Report •

✔ Best Answer
August 28, 2014 at 19:03:56
Sorry. My script completely bad. here is the fixed version:

@echo off &setlocal enabledelayedexpansion
for %%a in (????????????.pdf) do (
set x=%%a
echo ren %%a !x:~0,2!-!x!:~2,3!-!x:~5,2!-!x:~7,1!-!x:~8,4!.PDF
)
::====== not tested, so I left the "echo" in line 4. remove it if it works ok.
and also stupid me left off the extension, which M2's post reminded me.

message edited by nbrane



#1
August 27, 2014 at 11:18:30
@echo off &setlocal enabledelayedexpansion
for %%a in (????????????.pdf) do (
set x=%%a
echo ren %%a y=!x:~0,2!-!x!:~2,3!-!x:~5,2!-!x:~7,1!-!x:~8,4!
)
::====== not tested, so I left the "echo" in line 4. remove it if it works ok.

Report •

#2
August 28, 2014 at 01:32:26
::====== script starts here ===============
::
:: spacer.bat 2014-08-28 12:13:14.07
@echo off > NEWFILE & setLocal enableDELAYedeXpansioN

copy x\*.pdf > nul

:main
for /f "tokens=* delims= " %%a in ('dir/b *.pdf') do (
set N=%%~Na
set N=!N:~0,2!_!N:~3,3!_!N:~5,2!_!N:~7,1!_!N:~8,4!
echo ren %%a !N!.pdf
)
goto :eof
::====== script ends here =================

=====================
M2 Golden-Triangle


Report •

#3
August 28, 2014 at 06:09:57
nothing happen when i run the batch file

message edited by sushil261


Report •

Related Solutions

#4
August 28, 2014 at 19:03:56
✔ Best Answer
Sorry. My script completely bad. here is the fixed version:

@echo off &setlocal enabledelayedexpansion
for %%a in (????????????.pdf) do (
set x=%%a
echo ren %%a !x:~0,2!-!x!:~2,3!-!x:~5,2!-!x:~7,1!-!x:~8,4!.PDF
)
::====== not tested, so I left the "echo" in line 4. remove it if it works ok.
and also stupid me left off the extension, which M2's post reminded me.

message edited by nbrane


Report •

Ask Question