mercredi 25 décembre 2019

Yesterday date will compare to the filename of .txt

My codes are from some post here as well and I am using robocopy so that I can move the files instead of copy and pasting them.

Here are my information

**result** = my yesterdays date
**Source Path** = where the main file is.
**Destination Path** = where it should be move

I am trying to move a file wherein it was dated yesterday from source to destination.

set day=-1
echo >"%temp%\%~n0.vbs" s=DateAdd("d",%day%,now) : d=weekday(s)
echo>>"%temp%\%~n0.vbs" WScript.Echo year(s)^& right(100+month(s),2)^& right(100+day(s),2)
for /f %%a in ('cscript /nologo "%temp%\%~n0.vbs"') do set "result=%%a"
del "%temp%\%~n0.vbs"
set "YYYY=%result:~0,4%"
set "MM=%result:~4,2%"
set "DD=%result:~6,2%"
set "result=%yyyy%%mm%%dd%"
echo %result%

FOR /R %C:\Users\JBP-Admin\Desktop\Pugad\Forback UP% %%G IN (*.txt) DO (
set file=%%~nG

ROBOCOPY "C:\Users\JBP-Admin\Desktop\Pugad\Forback UP" "C:\Users\JBP-Admin\Desktop\Pugad\Forback UP\Destination" "*.txt" /mov
If "%result%"=="*.txt" (
    echo Filename "%file%" has been backed up
) else (
    echo Filename "%file%" nothing to back up yesterday
)

Aucun commentaire:

Enregistrer un commentaire