windowscmdforfiles

Get File size in hex using forfiles


I am using this command in CMD to take all file size in a directory.

forfiles /s /c "cmd /c echo @file @fsize" >filelist.txt

There has someway to take this size but in hex format?

Example:

"00000000.png" 219457

to

"00000000.png" 50A6E

Solution

  • While this does not use FORFILES, it can be used in a windows cmd batch-file. Since this is a recursive search, I assume you would want the fully qualified path included to avoid problems when the same filename is used in multiple directories.

    powershell -NoLogo -NoProfile -Command ^
        "$q='\"';Get-ChildItem -File -Recurse ^| ForEach-Object {$($q+$_.FullName+$q) + ' ' + $($_.Length.ToString('X'))}"