In a previous thread, I got some amazing help and now have the code to rename a single file that I give as a parameter
The code I have is:
Code: Select all
@echo off
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"
set "stamp=%DD%%MM%%YYYY%.%HH%%Min%"
:loop
ren "%~1" "%~n1.%stamp%%~x1"
shift
if not "%~1"=="" goto :loop
I know the basic loop structure I need:
Code: Select all
for /f "delims=" %%a in (' dir *.jpg /b ') do (
ren "%%a" "%_LAST_SEGMENT_% !i!.jpg"
set /a i=i+1
)
The above is code that I have that helps me rename files so that they have the same name as the parent directory
I'm not sure how I would get the equivalents of %~1 and %~x1 ? (Since I'm not passing anything as a paramter)
Thanks to help from a previous post, I understand that these are special values relating to the first parameter
+ At the end, I need to move the renamed files to another directory
Any help would be great
Thanks
OM