foxidrive said:
double the percent signs (%=%%) in a batch file, as opposed to a command
line.
Very true, foxi - that will cure the immediate problem as posted.
The next problem is that "skip=3 tokens=5*" isn't universal or reliable.
It's not reliable because the last line of the "dir" report using this
structure has token5="free" which will attempt to perform CACLS on a
directory name "free ". It's not universal - I believe it assumes "am/pm"
time-format since on my system it only "hits" directorynames that contain
spaces - and then only the second-token-onwards of those (I use 24-hr
time-format.)
A far better solution would be
for /f "delims=" %%i in ('dir /b/a:d') do cacls "%%i"
The next problem in this thread is the actual requirement AIUI of the OP.
This appears to be a CSV file containing the ACL data (but no specification
as to precise format.) Leaving aside the minor change to this nebulous
requirement introduced by the "/a:d" filter for directories only, the
observation was made that the CACLS format was difficult to process and
'Neither is there a common delimiter/position to each "column" '. This last
assertion is debatable. The CACLS output is one of three forms:
1) filename[space]ACL-spec
2) [(length-of-filename+1) spaces]ACL-spec
2) [(length-of-filename+1+a few more) spaces]supplementary-ACL-spec
so to process it to a useful CSV-format, I'd expect
"filename","ACL-spec"
or
"filename","ACL-spec","supplementary-ACL-spec" (where
"supplementary-ACL-spec" may be "")
Since writing the file/directory-name to a tempfile and then executing
for %%i in (tempfilename) do set /a yLF=%%~zi-2
will set yLF to the length of the filename, producing the CSV format by
substringing the CACLS output isn't particularly hard, and I've got that
part working. The only bug I've found is where the target
file/directory-name contains a "poison character" - especially "&" which
kills off the substringing mechanism.
I've yet to find a way of removing the filename from a line such as
c:\106x\newest file with strange&characters!% hello BUILTIN\Administrators:F
NT AUTHORITY\SYSTEM:F
(where the "NT" in the second line is in the same column as the "B" of
"BUILTIN" in the first)
So at this point I'm stuck trying to solve someone else's problem
HTH
....Bill