Michal
I knew it would be something easy !
Sorry I couldnt finish this off without Sidewinder's help (cheers SW)
Graham
Try this
@echo off
CD /d p:\
REM grab todays date into variables
set MM=%Date:~3,2%
set DD=%Date:~0,2%
set YYYY=%Date:~6,4%
REM Add the date variables to the log name
REM putting the date in this order will sort the files sensibly
Set LogFile="e:\NewFiles_%YYYY%-%MM%-%DD%.Log"
REM create the vb script
>c:\evaluate.vbs echo Wscript.echo eval(WScript.Arguments(0))
REM extract todays date less 7 days
set OldestDate=
for /f "delims=" %%A in ( ' cscript //nologo c:\evaluate.vbs "Date -7" ' ) do set OldestDate=%%A
REM tidy
del c:\evaluate.vbs
REM break up the date into constituent parts
REM 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 '-' separators
set OldestDate=%MM%-%DD%-%YYYY%
REM add the new entry to the log
>> %LogFile% Echo %DATE% %TIME%
>> %LogFile% Echo Since : %OldestDate%
net use p:|find "Remote name">> %LogFile%
REM list the files that would be copied if we really were doing a copy
REM force it to believe that the target NonExistentDirectory is a directory
REM and echo the name & time for each
for /f "delims=" %%A in ( ' xcopy /l /i /d:%OldestDate% *.* NonExistentDirectory ' ) do call :ProcessEach "%%A"
REM tidy up the log
>> %LogFile% Echo ========================================
REM ----------------------------
REM Release mapped drive
REM ----------------------------
E:
goto :EOF
:ProcessEach
>> %LogFile% echo %~f1 %~t1
goto :EOF