Tuesday, 15 March 2011

batch scripting with date function -


I have a task that I know how to do it in other languages, but Windows Batch / CMD requires me one Is a little amazed.

I had a requirement that I should write in batch script to copy the set of axle files up to c: to e: drive and In the D: drive, I must keep a file of 7 days based on the file name with date. > a_20120101.xls a_20120102.xls b_20120103.xls

should contain only the files for the last 7 days. Whenever there are files on the eighth day, the day 1 files should be deleted properly, only 7 days of file should be.

Thank you in advance ....

Was written for one purpose:

  @echo if off% 1! ==! (Echo removes all files except the latest 7 echo formatting:% 0 ^  exit / b) If not then% 1 does not exist in the echo directory% 1! & Amp; (% Dir / od / b / ad ^ | findstr / n '') (If %% GTR 7 "for / extrusion / b1 pushed% 1 / f" tokens = 1,2 delims = del %% b ") Popd  

While running with care!


No comments:

Post a Comment