This is a Windows 10 batch file question. I need to rename a series of files based on their names, but I only know part of the name for each file. With guidance from various pages on this site, I've tried the following steps. I tired the commented FOR but they didn't work. The REN command worked partially, but didn't preserve the entire original filename. I hope the following code will help you understand what I'm trying to do.
::Append 00 as a prefix to the name of whatever filename contains a specific string
::
setlocal
::set fname=
set fname=ADPMasterControl.pdf
::SITE EXAMPLE: for %a in (prefix*.txt) do @(set "fname=%a" & call ren "%fname%" "%fname:*prefix=%")
::for %a in (*ADPMasterControl.pdf) do @(set fname=%a & call ren %fname% "%fname:*prefix=%")
::for %a in (*ADPMasterControl.pdf) do @(set fname=%a & call ren %fname% "00 %fname%")
::for %a in (*ADPMasterControl.pdf) do (set fname=%a & call ren %fname% "00 %fname%")
ren *%fname% "00 *%fname%" <----------this KINDA SORTA works but it's dropping/replacing the first three characters of the original filename instead of just appending "00 " to the beginning
Desired:
ren 1234_###_1_4641_2020-07-30_ADPMasterControl.pdf "00 1234_###_1_4641_2020-07-30_ADPMasterControl.pdf"
What actually happened:
ren 1234_###_1_4641_2020-07-30_ADPMasterControl.pdf "00 4_###_1_4641_2020-07-30_ADPMasterControl.pdf"
echo . > "08 Pays to Non-Actives.txt" <---THIS WORKED FINE
pause
exit
jren "^" "00 " /fm "*ADPMasterControl.pdf"