Sulcata
asked on
Delete all files in tree over 7 days old
I need a script or line that can be added to this one to delete all folders and files created by the following script that are older than 7 days old. Will be run from XP,2000 and 98se.
REM This backs up the H:\ drive at log off
REM Place in user_config/windows_settin gs/scripts /logoff
REM This section was found at https://www.experts-exchange.com/questions/20268763/Create-subdirectory-name-based-on-date-and-time.html
REM ----------------- this creates a date string
for /f "tokens=2-4 delims=/ " %%a in ('Date /T') do set DateVar1=d%%c%%a%%b
for /f "tokens=1-3 delims=: " %%a in ('TIME /T') do set TimeVar1=t%%a%%b%%c%
SET DateVar=%DateVar1%\%TimeVa r1%
MD c:\DailyLocal\%VarVar%
REM ----------------- this determines if the directory exists before creating one
IF NOT EXIST C:\DailyLocal\%DateVar%\NU L MD C:\DailyLocal\%DateVar%
REM copies file from and to directory
xcopy /E /Y /Q /k /I H\:*.* c:\DailyLocal\%DateVar%
REM This backs up the H:\ drive at log off
REM Place in user_config/windows_settin
REM This section was found at https://www.experts-exchange.com/questions/20268763/Create-subdirectory-name-based-on-date-and-time.html
REM ----------------- this creates a date string
for /f "tokens=2-4 delims=/ " %%a in ('Date /T') do set DateVar1=d%%c%%a%%b
for /f "tokens=1-3 delims=: " %%a in ('TIME /T') do set TimeVar1=t%%a%%b%%c%
SET DateVar=%DateVar1%\%TimeVa
MD c:\DailyLocal\%VarVar%
REM ----------------- this determines if the directory exists before creating one
IF NOT EXIST C:\DailyLocal\%DateVar%\NU
REM copies file from and to directory
xcopy /E /Y /Q /k /I H\:*.* c:\DailyLocal\%DateVar%
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
rin1010, you are right about the variables not working under win98. We are 3 wks away from upgrading those systems so I am not going to worry about them to much.
Thank you for the programs they work great!
Thank you for the programs they work great!
https://www.experts-exchange.com/questions/20164223/Deleting-Files-in-DOS-based-on-Date.html
There are links to utils for date deleting and also a batch file that does that as well