I want to do echo
only checking the date from one file with forfiles
:
forfiles /m "C:\Backups\TEST.bak" /c "cmd /c echo test" /d -1
But it returns me an error :
The System cannot find the file specified.
And that file it exists and the directory is correct.
If use forfiles
in the same directory (without file) it works fine:
forfiles /p "C:\Backups" /c "cmd /c echo test" /d -1
What am I doing wrong?
The problem is that forfiles requires a directory as parameter. You are giving it a file instead. This won't work.
Instead you should do this:
FOR %%a in (C:\Backups\TEST.bak) DO SET FileDate=%~ta
This will store the file's modifed date in %FileDate%
.
forfiles /p "c:\Backups" /m "test.bak" /d -1 /c "cmd /c echo @fdate @ftime"
/p
needs a folder to start searching
/m
needs a file mask to indicate what to search
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.