Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.
@echo offREM create the vb script>evaluate.vbs echo Wscript.echo eval(WScript.Arguments(0))REM extract todays date less 7 daysfor /f "delims=" %%A in ( ' cscript //nologo evaluate.vbs "Date -7" ' ) do set OldestDate = %%AREM tidydel evaluate.vbsREM break up the date into constituent partsREM Note - the date is parsing UK format dates,REM swap the MM and DD in the lines belowREM for US formatset MM=%OldestDate:~3,2%set DD=%OldestDate:~0,2%set YYYY=%OldestDate:~6,4%REM reconstruct US format with '-' separatorsset OldestDate=%MM%-%DD%-%YYYY%REM list the files that would be copied if we really were doing a copyREM force it to believe that the target NonExistentDirectory is a directoryREM and echo the name & time for eachfor /f "delims=" %%A in ( ' xcopy /l /i /d:%OldestDate% *.* NonExistentDirectory ' ) do echo %%A %%~tA
@echo offCD /d F:\FolderForFilesSet LogFile="d:\logs\NewFiles.Log"REM create the vb script>evaluate.vbs echo Wscript.echo eval(WScript.Arguments(0))REM extract todays date less 7 daysfor /f "delims=" %%A in ( ' cscript //nologo evaluate.vbs "Date -7" ' ) do set OldestDate = %%AREM tidydel evaluate.vbsREM break up the date into constituent partsREM Note - the date is parsing UK format dates,REM swap the MM and DD in the lines belowREM for US formatset MM=%OldestDate:~3,2%set DD=%OldestDate:~0,2%set YYYY=%OldestDate:~6,4%REM reconstruct US format with '-' separatorsset OldestDate=%MM%-%DD%-%YYYY%REM add the new entry to the log>> %LogFile% Echo %DATE% %TIME% REM list the files that would be copied if we really were doing a copyREM force it to believe that the target NonExistentDirectory is a directoryREM and echo the name & time for eachfor /f "delims=" %%A in ( ' xcopy /l /i /d:%OldestDate% *.* NonExistentDirectory ' ) do call :ProcessEach %%AREM tidy up the log>> %LogFile% Echo ========================================goto :EOF:ProcessEach>> %LogFile% echo %%~fA %%~tAgoto :EOF
@echo offCD /d e:\picturesREM grab todays date into variablesset MM=%Date:~3,2%set DD=%Date:~0,2%set YYYY=%Date:~6,4%REM Add the date variables to the log nameREM putting the date in this order will sort the files sensiblySet LogFile="e:\NewFiles_%YYYY%-%MM%-%DD%.Log"REM create the vb script>evaluate.vbs echo Wscript.echo eval(WScript.Arguments(0))REM extract todays date less 7 daysfor /f "delims=" %%A in ( ' cscript //nologo evaluate.vbs "Date -7" ' ) do set OldestDate = %%AREM tidydel evaluate.vbsREM break up the date into constituent partsREM Note - the date is parsing UK format dates,REM swap the MM and DD in the lines belowREM for US formatset MM=%OldestDate:~3,2%set DD=%OldestDate:~0,2%set YYYY=%OldestDate:~6,4%REM reconstruct US format with '-' separatorsset OldestDate=%MM%-%DD%-%YYYY%REM add the new entry to the log>> %LogFile% Echo %DATE% %TIME% REM list the files that would be copied if we really were doing a copyREM force it to believe that the target NonExistentDirectory is a directoryREM and echo the name & time for eachfor /f "delims=" %%A in ( ' xcopy /l /i /d:%OldestDate% *.* NonExistentDirectory ' ) do call :ProcessEach %%AREM tidy up the log>> %LogFile% Echo ========================================goto :EOF:ProcessEach>> %LogFile% echo %%~fA %%~tAgoto :EOF
set MM=%OldestDate:~3,2%set DD=%OldestDate:~0,2%set YYYY=%OldestDate:~6,4%REM reconstruct US format with '-' separatorsset OldestDate=%MM%-%DD%-%YYYY%
@echo offCD /d e:\picturesREM grab todays date into variablesset MM=%Date:~3,2%set DD=%Date:~0,2%set YYYY=%Date:~6,4%REM Add the date variables to the log nameREM putting the date in this order will sort the files sensiblySet LogFile="e:\NewFiles_%YYYY%-%MM%-%DD%.Log"REM create the vb script>evaluate.vbs echo Wscript.echo eval(WScript.Arguments(0))REM extract todays date less 7 daysset OldestDate=for /f "delims=" %%A in ( ' cscript //nologo evaluate.vbs "Date -7" ' ) do set OldestDate=%%AREM tidydel evaluate.vbsREM break up the date into constituent partsREM Note - the date is parsing UK format dates,REM swap the MM and DD in the lines belowREM for US formatset MM=set DD=set YYYY=set MM=%OldestDate:~3,2%set DD=%OldestDate:~0,2%set YYYY=%OldestDate:~6,4%REM reconstruct US format with '-' separatorsset OldestDate=%MM%-%DD%-%YYYY%REM add the new entry to the log>> %LogFile% Echo %DATE% %TIME% REM list the files that would be copied if we really were doing a copyREM force it to believe that the target NonExistentDirectory is a directoryREM and echo the name & time for eachfor /f "delims=" %%A in ( ' xcopy /l /i /d:%OldestDate% *.* NonExistentDirectory ' ) do call :ProcessEach %%AREM tidy up the log>> %LogFile% Echo ========================================goto :EOF:ProcessEach>> %LogFile% echo %~f1 %~t1goto :EOF
@echo offCD /d e:\picturesREM grab todays date into variablesset MM=%Date:~3,2%set DD=%Date:~0,2%set YYYY=%Date:~6,4%REM Add the date variables to the log nameREM putting the date in this order will sort the files sensiblySet LogFile="e:\NewFiles_%YYYY%-%MM%-%DD%.Log"REM create the vb script>evaluate.vbs echo Wscript.echo eval(WScript.Arguments(0))REM extract todays date less 7 daysset OldestDate=for /f "delims=" %%A in ( ' cscript //nologo evaluate.vbs "Date -7" ' ) do set OldestDate=%%AREM tidydel evaluate.vbsREM break up the date into constituent partsREM Note - the date is parsing YYYY-MM-DD format dates,set MM=set DD=set YYYY=set MM=%OldestDate:~5,2%set DD=%OldestDate:~8,2%set YYYY=%OldestDate:~0,4%REM reconstruct US format with '-' separatorsset OldestDate=%MM%-%DD%-%YYYY%REM add the new entry to the log>> %LogFile% Echo %DATE% %TIME%>> %LogFile% Echo Since : %OldestDate%REM list the files that would be copied if we really were doing a copyREM force it to believe that the target NonExistentDirectory is a directoryREM and echo the name & time for eachfor /f "delims=" %%A in ( ' xcopy /l /i /d:%OldestDate% *.* NonExistentDirectory ' ) do call :ProcessEach %%AREM tidy up the log>> %LogFile% Echo ========================================goto :EOF:ProcessEach>> %LogFile% echo %~f1 %~t1goto :EOF
>> %LogFile% echo %~f1 %~t1
[code]>> %LogFile% echo %~f1 %~t1