mardi 29 décembre 2015

Batch code if date created is less than 24 hours

I have already written here for this problem, we solved it but now I have to add this "if the file was created in the last 24 hours copy it else don't". I have found several examples online but I just cant seem to be able to figure the Commant syntax out. I would really apreciate some help with this ... here is the website i found :

http://ift.tt/1OiJ0yW

and here is my code:

ECHO OFF
set ReadFolder1="C:\Users\ugrum\Desktop\new"    
set Destination="C:\Users\ugrum\Desktop\Zacasnamapa"
set sevenZipDir="C:\Program Files\7-Zip\7zG.exe"
set currentDate=%date%

IF NOT EXIST %Destination% MKDIR %Destination%

FOR /R %ReadFolder1% %%G IN (*_NOT*) DO (
    ECHO %%G 
    FOR %%f IN %%G DO SET filedatetime=%%~tf
    IF %currentDate% - %filedatetime:~0, 10% <= 24      
    XCOPY "%%G" %Destination% /C
)

%sevenZipDir% a -tzip neustrezne.zip %Destination%
RMDIR /Q /S %Destination%

PAUSE

I know the if is wrong but i have no idea how to get it right.

Aucun commentaire:

Enregistrer un commentaire