Trying to iterate through all files and folders

  • Thread starter Thread starter Celler Dweller
  • Start date Start date
C

Celler Dweller

Hi all,
What I would like to do is get the file permissions from every file and
folder and send it to a text file. What I have,

FOR /R %%var in(*) DO xcacls.exe %%var >>File.acls.txt

The error I’m getting
%var was unexpected at this time

I’ve tinkered around with things to the point that that I’m just
spinning my wheels.
Can someone throw me a hint?
TIA
Dave
 
The variables need to be single letters, var is 3 letters. Use single
percent signs from the command line:
FOR /R %v in(*) DO xcacls.exe %v >>File.acls.txt

And use doubel percent signs from a batch file:
FOR /R %%v in(*) DO xcacls.exe %%v >>File.acls.txt


Read the syntax:

C:\>For /?
Runs a specified command for each file in a set of files.

FOR %variable IN (set) DO command [command-parameters]

%variable Specifies a single letter replaceable parameter.
(set) Specifies a set of one or more files. Wildcards may be used.
command Specifies the command to carry out for each file.
command-parameters
Specifies parameters or switches for the specified command.

To use the FOR command in a batch program, specify %%variable instead
of %variable. Variable names are case sensitive, so %i is different
from %I.
....
<snip>
 
I clicked Send too soon on the last one. There are 2 more problems:

1. There needs to be a space between in and ()

2. You should put double quotes around the file names in case there are
spaces in some of the names:

For /R %v in (*) DO @xcacls.exe "%v" >>File.acls.txt
 
Celler Dweller said:
Hi all,
What I would like to do is get the file permissions from every file and
folder and send it to a text file. What I have,

FOR /R %%var in(*) DO xcacls.exe %%var >>File.acls.txt

The error I’m getting
%var was unexpected at this time

I’ve tinkered around with things to the point that that I’m just
spinning my wheels.

If you are running on XP or w2k3, try this:

CACLS * /t >file.acls.txt

/Al
 
Back
Top