0

I need to create a Batch file for keeping the 6 latest files in a directory. I have a prototype but need some help with the commands used.

 for /f "skip=6 eol=: delims=" %F in ('dir /b /o-d /a-d *.pdf') do @del "%F"

What do /f,eol, and delims do in this script snippet? Can anyone explain or point me to where I can find more information?

James Patrick
  • 32
  • 1
  • 7
Swetha
  • 11
  • 4
  • https://ss64.com/nt/for_f.html That might be a start. It notes what all those things you're asking are for. – Kevin Jan 30 '18 at 06:04
  • What you have posted is not, in any way, a batch file and if you find out what the `R` stands for in `R&d` you'll have the answer to your question! – Compo Jan 31 '18 at 02:02

1 Answers1

0

/f says you are parsing a file or output of a command. Skip=6 says skip first 6 lines or the oldest 6 files from Dir command. eol is unnecessary. Delims=<nothing> says don't break the line on spaces.

All this is in for /?. Also see dir /?. See http://stackoverflow.com/questions/41030190/command-to-run-a-bat-file/41049135#41049135 for a cheat sheet.

ACatInLove
  • 175
  • 3
  • dir /b /o-d /a-d means – Swetha Jan 30 '18 at 06:30
  • He didn't ask that but I gave a for him to generically answer any question like this. `dir /?`. – ACatInLove Jan 30 '18 at 06:47
  • when i use this command for /f "skip=6 eol=: delims=" %F in ('dir /b /o-d /a-d *.*') do @del "%F" I am getting Could Not Find D:\FilesGenerator\MLPANO - AWD No Policy Number_15_01_2017.pdf – Swetha Jan 31 '18 at 11:11