Hi Michal
No, you are asking very good questions!
You would save it with a .bat extension, the small vbscript that is used is created by the batch, this is because date and time manipulation is simple in vbscript but nearly impossible in batch files
The XCopy is not actually copying anything - but listing the files that would be copied; the /L tells it not to copy anything
If you schedule this then you will not see any output, I suggest that the list of files is placed in the log also.
Denmark uses the correct date format
so that you will not need to change the script
This is the latest version, you will need to change the drive and directory in line 2 to be the folder that you wish to monitor
In Line 3, a variable is created to hold the location of your logfile, you will have to change this also to be the name and location of your log
@echo off
CD /d F:\FolderForFiles
Set 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 days
for /f "delims=" %%A in ( ' cscript //nologo evaluate.vbs "Date -7" ' ) do set OldestDate = %%A
REM tidy
del evaluate.vbs
REM break up the date into constituent parts
REM Note - the date is parsing UK format dates,
REM swap the MM and DD in the lines below
REM for US format
set MM=%OldestDate:~3,2%
set DD=%OldestDate:~0,2%
set YYYY=%OldestDate:~6,4%
REM reconstruct US format with '-' separators
set 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 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 ========================================
goto :EOF
:ProcessEach
>> %LogFile% echo %%~fA %%~tA
goto :EOF
One problem with this is that the last line of each log entry will say xxx File(s) Copied, with the path preceding it