Hi all,
I have yet another drama,So the problem is I have been recieving a high number of *.PDF files for people that do not have the persons name in the file.
EG,
i have currently,
Folder (Brown, John)
File (VST123456_ABC.PDF)I am trying ot achieve a BAT file that can scan all the folders and sub folders in a directory for any *.PDF files and rename the *.PDF to the folder it is in.
What im trying to achieve
Folder (Brown, John)
File (JohnBrownVST123456_ABC.PDF)So each *.PDF is already placed in the correct folder but the name is not correct.
I am thinking something like, Search DIR for *.PDF
IF found rename *PDF using Token,1 from DIRRepeat through each directory
Those parentheses are what's gonna drive you nuts. whoever designed the filenames should have to fix his/her idiocies.
The following command is one that renames and moves, @echo off
cls
setlocal enabledelayedexpansionfor /f "delims=" %%A in ('dir /a-d /b /tc "*.PDF"') do (
md "%%~nA"set file=%%~tA
set file=!file:~6,4!!file:~3,2!!file:~0,2!_!file:~11,2!!file:~-2!.pdf
move "%%A" "%%~nA\!file!"> nul
)Can this command not be tweeked to achive my goal?
all i want to do is change the name of a file to match the directory it is in.
If anyone can suggest any good reading material so i can help myself
well, i doubt this will help, but you're welcome to try it: @echo off & setlocal enabledelayedexpansion
for /f "tokens=*" %%a in ('dir /b /s *.pdf') do (
set test=%%~pa
set test=!test:~0,-1!
for /f "tokens=*" %%b in ("!test!") do set xx=%%~nb
for /f "tokens=1,2 delims=(,) " %%c in ("!xx!") do set yy=%%d%%c
set zz=%%~na
set zz=!yy!!zz:(=!.pdf
echo ren %%a !test!\!zz!
)
)
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |