

This is nice and clean and with a minor edit we can paste it directly into the CMD Prompt which is nicer still This is because we are not using DelayedExpansion, Calling a Label, or using Temp variables so by changing the %%s to %s, we can then Paste this directly into the CMD Line which is often more convenient when doing these sorts of operations: You can also forgo the call to a label entirely without needing delayed expansion by using a second loop, as a matter of preference I think this is quite a bit cleaner! offįOR /F "Tokens=1-3 Delims=/ " %%a IN ('echo.%%~tA') DO ( Notice how above we are dropping the Time off immediately by not wrapping it in quotes since you don't want that to be part of the file name.

I notice that you only want the date, not the time so you can do that as follows using your existing Call to a label, There is also no need to use FOR /R in this case so I'll use a normal for loop: offįOR %%A IN ("F:\images 2017+\*.jpg") DO ( I am CDing into the same directory as the images are, then using the passed variables to locate the correct image (The date is one of the passed variables, and shows up in the echo command).

ThisIsMyFile.jpg made at 5-13-2017, would become thisIsMyFile 5-13-2017.jpg jpg file in "images 2017+", the date which that file was created would be stuck onto the end after a space.

REM batch file is placed in top of F drive, same as "images 2017+"įOR /R "F:\images 2017+" %%F in (*.jpg) do call :renER "%%~nF" "%%~tF"įor every. I did see someone mention on another thread to use delayed expansion, I would be up for using this if someone could give a better explanation than the /? command. I tried having all the code in one for-loop, when that didn't work I tried using batch functions, no dice. I am running Windows 10, and accessing the images off a flash drive (hence the short file path). I am trying to rename every image in a directory to add the date that each file was created, however, I keep either getting "invalid syntax" or "A duplicate file name exists, or the file cannot be found"
