Does anyone see any inherent benefits to using FORFILES instead of some flavor of a FOR loop? FORFILES seems awkward and potentially slow to me since it spawns a new CMD for each path found.
The only potential benefits I see is it can give you a relative path (@RELPATH), it can differentiate between a file and a folder (@ISDIR), and it can give you the file last modified time including seconds (@FTIME).
Dave Benham
What is FORFILES good for
Moderator: DosItHelp
Re: What is FORFILES good for
I guess I just use it mostly for the /D option.
Re: What is FORFILES good for
Oooh, I didn't read that option carefully enough. That is useful. Thanks
Dave Benham
Dave Benham
Re: What is FORFILES good for
Adding to an old thread
A post on Stack Overflow noted that Forfiles @fsize doesn't work with filesizes over 10 digits.
But it's even worse than that - it corrupts the digits that are reported.
Using this command it gives the output below:
7080760325 "Coverse" 3/12/2012,22:36:19
and this is what DIR reports ( Win 8 )
03/12/2012 22:36 19,965,662,213 Coverse.7z
Pretty nasty.
A post on Stack Overflow noted that Forfiles @fsize doesn't work with filesizes over 10 digits.
But it's even worse than that - it corrupts the digits that are reported.
Using this command it gives the output below:
Code: Select all
@forfiles /p . /m c*.7z /c "cmd /c echo @fsize @fname @fdate,@ftime"
7080760325 "Coverse" 3/12/2012,22:36:19
and this is what DIR reports ( Win 8 )
03/12/2012 22:36 19,965,662,213 Coverse.7z
Pretty nasty.
Re: What is FORFILES good for
Well I still like the FORFILES trick to print just about any character. Can't remember if that was Dave who brought that up as well.
Re: What is FORFILES good for
It's a good tool in it's place - it's good to know it's limitations though.