Search code examples
windowsbatch-filecmdforfiles

Suppress output string using FORFILES command


I want ignore the seconds of the output @ftime using forfiles:

forfiles /P "%userprofile%\Desktop\folder" /M "test.rar" /C "cmd /c echo sucessufull at %@ftime:~0,2%:%@ftime:~3,2%h"

Tried using this way, but I think forfiles doesn't allow use of %.


Solution

  • Here's a basic example of your command directly using , to stay on topic:
    @ForFiles /P "%UserProfile%\Desktop\folder" /M "test.rar" /C "Cmd /V /C Set _=@FTime&Echo successful at !_:~,5!"
    

    And a more complete/robust example:

    @"%__AppDir__%forfiles.exe" /P "%UserProfile%\Desktop\folder" /M "test.rar" /C "0x22%__AppDir__%cmd.exe0x22 /V /C If @IsDir==FALSE (Set 0x22_=@FTime0x22 & Echo successful at !_:~,5!)"