This problem is from the scheduler task, batch program, or the files in a folder that I want to delete it using the batch program? and this is the batch program:
forfiles /p "D:\nameOfFolder" /s /m *.* /d -7 /c "cmd /c del @path"
This problem is from the scheduler task, batch program, or the files in a folder that I want to delete it using the batch program? and this is the batch program:
forfiles /p "D:\nameOfFolder" /s /m *.* /d -7 /c "cmd /c del @path"
On
Are you sure you even have such files?
I tried the following (very similar) command:
forfiles /p "C:\Temp_Folder" /s /m . /d -7 /c "cmd /c echo @path"
ERROR: No files found with the specified search criteria.
One thing I noticed, is that the name of the directory should not end with a backslash:
forfiles /p "C:\Temp_Folder" is working fine.
forfiles /p "C:\Temp_Folder\" is not working.
On
. on its own is not a valid searchmask to supply to /m.
You ned to use *.* (all) *.ext (the supplied extension) *string*.* (files with names containing the string).
? is also supported as a searchmask to match any character. example: *.?a* would match any file with an extension type with a as the second character
Replace
/M *.*by/M *to even include files without extension, becauseforfilestreats wildcards differently than most other commands./M *may even be omitted since this is the default setting anyway.Regard that
forfilesiterates both files and directories, so you need to exclude the latter, becausedelmay try to delete its contents then. Therefore, implement a condition based on theforfiles-specific variable@isdir.As a side note, never append a trailing backslash to a (quoted) path, because something like
/P "D:\"would let the command fail since\"constitutes an escaped quotation mark forforfiles, ruining the command line. You may however specify/P "D:\.".