|
Answer» Below is the batch created...
echo off set /P month="Enter the month to RENAME the texts ex.(01-12)?"
set /P day="Enter the day to rename the texts ex.(01-31)?"
set /P year="Enter the year to rename the texts ex.(2013 etc.)?"
ren for %%F in (*.pdf) do copy "%month%-%day%-%year%" "J:\Ownership\Star\2014\Current Files%%month%-%day%-%year%_%%F"
Below are the pdf file names I am trying to append (I would like to remove the numbers and add %%month%-%day%-%year% after the strings e.g. Las Vegas_, Orlando_)
Star - Las Vegas_29_73062435338 Star - Orlando_72_44867093663Do you have to do this in a folder tree or only one folder?
Do you want to PUT in the current date automatically?
Please show the filenames before and AFTERWARD, so that we don't misunderstand.Thank you for the reply.
No only one folder. I want the date values inputted based on the questions that are asked below.
echo off set /P month="Enter the month to rename the texts ex.(01-12)?"
set /P day="Enter the day to rename the texts ex.(01-31)?"
set /P year="Enter the year to rename the texts ex.(2013 etc.)?"
Before
Star - Las Vegas_29_73062435338 Star - Orlando_72_44867093663
After
Star - Las Vegas 07-11-14 Star - Orlando 07-11-14Test this in a folder of copies of your PDF files:
Code: [Select]echo off :loop set /P "month=Enter the month to rename the texts ex.(01-12): " set /P "day=Enter the day to rename the texts ex.(01-31): " set /P "year=Enter the year to rename the texts ex.(2013 etc.): " echo( set "var=" set /p var=Is this correct? "%month%-%day%-%year%" Enter N for no or just press enter for yes: if defined var goto :loop
for /f "delims=" %%a in ('dir *.pdf /b /a-d ') do ( for /f "delims=_" %%b in ("%%a") do ( ren "%%a" "%%b %month%-%day%-%year%%%~xa" ) ) echo done pauseI tested it, but it seems that if there is a second or third underscore and strings afterwards then the batch leaves those file names alone.
Failed attempts
Star - TN_South Carolina_RM_120_186186107480
Star - FL_Tennessee_109_8752148231853
Successful attempts
Star - FL 07-11-14
Star - SC 07-11-14
Any advice?
Quote from: junior89 on July 11, 2014, 11:41:31 AM I tested it, but it seems that if there is a second or third underscore and strings afterwards then the batch leaves those file names alone.
Failed attempts
Star - TN_South Carolina_RM_120_186186107480
Star - FL_Tennessee_109_8752148231853
If they are PDF files then they will have been RENAMED to:
Star - TN 07-11-14
Star - FL 07-11-14
Your filenames have variations so this code REMOVES the text in a different way.
This uses a helper batch file called `repl.bat` (by dbenham) - download from: https://www.dropbox.com/s/qidqwztmetbvklt/repl.bat
Place `repl.bat` in the same folder as the batch file or in a folder that is on the path.
Code: [Select]echo off :loop set /P "month=Enter the month to rename the texts ex.(01-12): " set /P "day=Enter the day to rename the texts ex.(01-31): " set /P "year=Enter the year to rename the texts ex.(2013 etc.): " echo( set "var=" set /p var=Is this correct? "%month%-%day%-%year%" Enter N for no or just press enter for yes: if defined var goto :loop
dir *_*_*.pdf /b /a-d |repl "(.*)_.*_.*(\....)$" "ren \q$&\q \q$1 %month%-%day%-%year%$2\q" xi >renamepdf.bat call renamepdf.bat del renamepdf.bat
echo done pause Great! It works! Thank you so much!!!!!
|