windows - Batch script to delete subfolder and its contents which are older than 30 minutes -


I need a Windows 7 batch script that is sub-folder and its content is 30 minutes old

P> Example: forfiles -p% dump_path% -m . -d -% max_days% -c "cmd / c del / q @ path"

The above code is not just an example and an appropriate solution.

The file name in the echo is the same folder which is 30 since the last modified date Are more than minutes old. To enable it after the trial, remove the counterclock from the echo del "% ~ 1".

  @echo off if / i "% ~ 1" == "debug" set debug = :: :: removes regional differences :: XP Pro can have file names errors Because the small filename is set to Bug Settlelock / f "tokens = 2 delims ==" %% a in ('wmic OS localet time / value') set "DT = %% A" set "YY =% dt: ~ 2 , 2% "& amp; Set "YYYY =% dt: ~ 0,4%" & amp; Set "mm =% dt: ~ 4,2%" & amp; Set "DD =% dt: ~ 6,2%" set "hH =% dt: ~ 8,2%" & amp; Set "minimum =% dt: ~ 10,2%" & amp; Set "Sec =% dt: ~ 12,2%" set "stamp =% YYYY %% MM %% DD %% HH %% minimum%"% debug% Echo Current time "% Stamp%" Call: Datetime% Stamp To call%, "Checkmin" "%% ~ FA" Pause: EOF: Checkman's set "Filestamp =" set "filemans =" ​​set "minsol =" set "YY =" & amp; Set "YYYY =" & amp; Set "mm =" & amp; Set "DD =" set "hH =" & amp; Set "Min =" & amp; Set "sec =" & amp; Set "dt =" set "file =% ~ sf1" :: Finally, the modified WMIC DatAFILE can use CreationDate instead of the name WHERE = "% file: \ = \\%" is finally modified. Search "." & Gt; For file.tmp, set / f %% a in (file.tmp) "dt = %% a" set "YY =% dt: ~ 2,2%" & amp; Set "YYYY =% dt: ~ 0,4%" & amp; Set "mm =% dt: ~ 4,2%" & amp; Set "DD =% dt: ~ 6,2%" set "hH =% dt: ~ 8,2%" & amp; Set "minimum =% dt: ~ 10,2%" & amp; Set "Sec =% dt: ~ 12,2%" set "filestamp =% YYYY %% MM %% DD %% HH %% minimum%" dell file.tmp 2 & gt; Nul% debug% echo file time "% filestamp%" if not defined: EOF call: date time% filestamp% fileman set / a minimum =% abmin% -% fileman%% debug% copy now:% now min % File:% Filemans% File:% minsold% "% ~ 1"% Pause debug% If% Missed% gtr 30 dumb "% ~ 1" goto: EOF: DateType Settlelock set yy =% 1 & amp; Set mm =% 2 & amp; Set dd =% 3 & amp; Set hh =% 4 & amp; Set nn =% 5 If set 1% yy% LSS 200 1% i.e.% LSS 170 (set yy = 20% yy%) set other (set yy = 19% yy%) / one DD = 100% dd %%% 100, Mm = 100% mm %%% 100 set / az = 14-mm, z / = 12, y = yy + 4800-z, m = mm + 12 * z-3, j = 153 * m + 2 set / aj = J / 5 + DD + Y * 365 + Y / 4-y / 100 + y / 400-2472633 if 1% HH% LSS 20 set HH = 0% HH% if / i {% nn: ~ 2,1 %} E.k. {if} "ah" % Hh% "EQU" 12 "set HH = 00 if / i {% nn: ~ 2,1%} gEQ {a} set nn =% nn: ~ 0,2% set / a hH = 100% hH %% % 100, NN = 100% NN %%% 100, J. = J * 1440 + HH * 60 + NN Endlocal and set% 6 =% J% and goto: EOF  

Comments