Format datetime from a files modified date
Posted: 29 Aug 2013 13:25
Is there anyway to format the datetime from the modified date of a file to the format below i tried multiple things but have had no luck. What im trying to accomplish here is to copy any files greater than or less than a date range a user inputs in the following format 120101 120731.
YYMMDDstart YYMMDDend
currently the date modiified displays like so..
1/1/2013 7:26 AM
I need it to be in this format -> YYMMDD (130101)
YYMMDDstart YYMMDDend
currently the date modiified displays like so..
1/1/2013 7:26 AM
I need it to be in this format -> YYMMDD (130101)
Code: Select all
@echo on
setlocal EnableDelayedExpansion
if "%2" neq "" goto begin
echo Usage: %0 YYMMDDstart YYMMDDend
echo/
echo For example: %0 120101 120731
rem set /p DT="Enter Start Date And End Date: "
rem %0 %DT%
rem hardcoded date for example
%0 120101 120731
goto :EOF
:begin
for %%f in ("F:\TEST & sample\sampleh\Final\test\*tse.*") do (
for /F "tokens=1-4 delims=." %%a in ("%%f") do (
set filedatetime=%%~tF
if %%~tf geq %1 if %%~tf leq %2 (
pause
copy /Y "%%f" "F:\TEST & sample\sampleh\Final\copiedfiles\"
)
)
)