batch scripting with date function -


have task assigned me know how other languages, windows batch/cmd requirement has me little baffled.

i had requirement should write batch script copy set of excel files c: drive e: drive , in d: drive should place 7 days files based on file name date .

a_20120101.xls a_20120102.xls b_20120103.xls 

in d: drive there should last 7 days files . when ever 8th day files comes day1 files should deleted right there should 7 days files.

thanks in advance....

i wrote 15 years ago such purpose:

@echo off  if %1!==! (   echo deletes files except newest 7   echo   syntax: %0 ^<directory^>   exit/b )  if not exist %1 echo directory %1 not exist! & exit /b 1 pushd %1  /f "tokens=1,2 delims=:" %%a in ('dir/o-d/b/a-d ^|findstr /n .') (   if %%a gtr 7 "del %%b" )  popd 

run care though!


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -