I want to make a move executable files with more than 5 minutes. Do not know how to compare the modified date of the file VS the system date.
@echo off
for %%f in (*.log) do (
move %%~nf.log \Procesados
)
exit
I want to make a move executable files with more than 5 minutes. Do not know how to compare the modified date of the file VS the system date.
@echo off
for %%f in (*.log) do (
move %%~nf.log \Procesados
)
exit
One way is to download findutils and coreutils then do this:
gnu_find . -type f -mmin +05 -exec cp "{}" c:\destination ;
that's all you need. Date calculation is taken care of as well. No need to reinvent your own date calculation.
EDIT As per OP queries:
In below example FIND searches for all the files in current directory (.)
gnu_find . -type f -mmin +5 -exec cp "{}" C:\destination\folder ;
But, you can specify a directory to search as you wish:
gnu_find D:\source\folder -type f -mmin +5 -exec cp "{}" E:\destination\folder ;
To learn more options of FIND utility, read here.....
This batch will keep running untill you stop it and if it finds a file is older than Xtime it moves it to a destination. Put the batch in the same folder with the .log files.
@echo off
setlocal enabledelayedexpansion
:Loop
set "Xtime=5"
For /F "tokens=2,* delims=:" %%a in ('echo %time%') Do set CurrTime=%%a
For %%a in (*.log) Do (
For /F "tokens=3 delims=: " %%b in ("%%~ta") Do (
set "Ftime=%%b"
set /a check = CurrTime - Ftime
IF !check! GEQ !Xtime! ( MOVE /Y %%~fsa path_to_destiantion_folder
) Else ( goto next )
)
)
:next
goto Loop
change the Xtime to suit your needs.