2

I am new at this, but I am trying to make a .BAT file that can delete all files in a folder that is older then X days. I am able to do this using the Command Line, but when i use it inn a .BAT file it does't do anything.

My example:

@echo off
ForFiles /p “C:\Users\Username\Pictures\2018-03” /s /d -1 /c “cmd /c del @file”
end

If I use the line: ForFiles /p “C:\Users\Username\Pictures\2018-03” /s /d -1 /c “cmd /c del @file” in cmd it will delete all files older then 1day.

Aserre
  • 4,916
  • 5
  • 33
  • 56
Zerow
  • 21
  • 1
  • 1
  • 2
  • 3
    You have typographic quotation marks `“` and `”`, which are not understood by `cmd`; you have to use the normal ones `"` in your code! And `end` is not a valid `cmd` command, by the way... – aschipfl Jul 11 '18 at 14:33

1 Answers1

0

Thank you aschipfl that solved it.

Changing the quotation marks from to " and removing the end fixed it. The BAT file now only has this line: ForFiles /p "C:\Users\Username\Pictures\2018-03" /s /d -1 /c "cmd /c del @file" and it now works

Zerow
  • 21
  • 1
  • 1
  • 2