Since compact shows a C
on a fixed position:
134217728 : 0 = 1.0 a 1 C BigFile.Dummy
123456789012345678901234567890123
= 33th position indicates if it is NTFS compressed.
Since all compressed files are listed by compact with a C in the 33th character (at least on where i run it, maybe other languages are different), maybe this command can help:
compact /A | findstr /R ^................................C
/R indicates that the following is a regular expression
^ is to indicate look from beggining of line
The 32 dots for ignoring 32st charaters of the line
Then the C to indicate must look for a C at the 33th position, that indicates it is NTFS compressed
What it does is list all files and then filter by looking for a C
on the 33th position from the begining of the line.
If want recursive, use a for loop that list all directories and run that command on each, like this big sample command (if typed directly on the command line):
(CD "C:\YourBaseDir\" && ECHO Listing NTFS compressed files and folders: && (compact /A /I | findstr /R ^................................C) && for /F "delims=" %a in ('DIR /AD/B/S') do @(CD "%a" && ECHO Listing NTFS compressed files and folders on: "%a" && (compact /A /I | findstr /R ^................................C)) & CD "C:\YourBaseDir\")
If you put the command inside a BATCH file, the %a
must double the %
, so must be like this (all in one big line):
(CD "C:\YourBaseDir\" && ECHO Listing NTFS compressed files and folders: && (compact /A /I | findstr /R ^................................C) && for /F "delims=" %%a in ('DIR /AD/B/S') do @(CD "%%a" && ECHO Listing NTFS compressed files and folders on: "%%a" && (compact /A /I | findstr /R ^................................C)) && CD "C:\YourBaseDir\")
Or for better reading on a BATCH file:
@ECHO OFF
CD "C:\YourBaseDir\"
ECHO Listing NTFS compressed files and folders:
compact /A /I | findstr /R ^................................C
for /F "delims=" %%a in ('DIR /AD/B/S') do @(
CD "%%a"
ECHO Listing NTFS compressed files and folders on: "%%a"
compact /A /I | findstr /R ^................................C
)
CD "C:\YourBaseDir\"
Warning: Compact will also show compressed folders, to avoid them a double for is needed.
The result is like this:
Listing NTFS compressed files and folders:
0 : 0 = 1.0 a 1 C a
134217728 : 0 = 1.0 a 1 C BigFile.Dummy
Listing NTFS compressed files and folders on: "D:\Temp\a"
0 : 0 = 1.0 a 1 C b
134217728 : 0 = 1.0 a 1 C Other.Dummy
Listing NTFS compressed files and folders on: "D:\Temp\a\b"
134217728 : 0 = 1.0 a 1 C Another.Dummy
Hope that helps, it is based on findstr allowing regular expresions, so please adapt the regular expression to you OS version and language.
This would be for showing only files (not folders) on the result listing (inside a BATCH file with good reading):
@ECHO OFF
CD "D:\YourBaseDir\"
ECHO Listing NTFS compressed files:
for /F "delims=" %%a in ('DIR /A-D/B') do @(
compact /A /I "%%a" | findstr /R ^................................C
)
for /F "delims=" %%a in ('DIR /AD/B/S') do @(
for /F "delims=" %%b in ('DIR /A-D/B "%%a"') do @(
ECHO Listing NTFS compressed files on: "%%a\"
compact /A /I "%%a\%%b" | findstr /R ^................................C
)
)
The trick to not show folders is to use a specific FOR to proccess only the files /A-D
parameter on the FOR
; at the cost of calling compact/findstr for each individual file.
And please note this one does not do CD
to change to the directory... it passes the full path to the file to compact as a parameter... warning with long paths !!!
The result is then like this (no folders shown):
Listing NTFS compressed files:
134217728 : 0 = 1.0 a 1 C BigFile.Dummy
Listing NTFS compressed files on: "D:\Temp\a\"
134217728 : 0 = 1.0 a 1 C Other.Dummy
Listing NTFS compressed files on: "D:\Temp\a\b\"
134217728 : 0 = 1.0 a 1 C Another.Dummy
It also could be improved (as all things on this world) using sed
(from GNU for windows) that let cut the file name part of the compact/findstr pair and also with an ECHO that concatenates the path and the sed
result.
Hope this can help with the task.