Using only standard commands, I have scripted CopyCreated.bat to perform the subject copy.
The syntax for using CopyCreated.bat is:
CopyCreated Folder YYYYMMDD Drive:
Where:
Folder is the path to the folder that contains the files that you wish to copy, like C:\MyFolder. YYYYMMDD is the date created that you wish to test, like 20040102. Drive: is the destination drive, or folder path, where the files created on or after YYYYMMDD will be copied to.CopyCreated.bat contains:
@echo off If \{%3\}==\{\} @echo Syntax: CopyCreated Folder YYYYMMDD Drive:&goto :EOF if not exist %1 Syntax: CopyCreated Folder YYYYMMDD Drive: - %1 not found.&goto :EOF if not exist %3 Syntax: CopyCreated Folder YYYYMMDD Drive: - %3 not found.&goto :EOF setlocal ENABLEDELAYEDEXPANSION set folder=%1 set ymd=%2 set drv=%3 for /f "Tokens=*" %%a in ('dir %folder% /b /a-d /s') do ( for /f "Tokens=1-3* Delims=/ " %%b in ('dir "%%a" /TC ^|find /I "%%~nxa"') do ( set /a YYYY=10000%%d%%10000 if !YYYY! LSS 2000 set /A YYYY=!YYYY! + 2000 set /a MM=100%%b%%100 if !MM! LSS 10 set MM=0!MM! set /a DD=100%%c%%100 if !DD! LSS 10 set DD=0!DD! set YYYYMMDD=!YYYY!!MM!!DD! if "!YYYYMMDD!" GEQ "%ymd%" @echo "%%a" if "!YYYYMMDD!" GEQ "%ymd%" if not exist "%drv%%%~Pa" MD "%drv%%%~Pa" if "!YYYYMMDD!" GEQ "%ymd%" copy "%%a" "%drv%%%~Pa*.*" ) ) endlocal
0 comments
Hide comments