lara400
lara400

Reputation: 4736

iterate through folders - how to do this?

I have the about 50 folder names and I want to run this command against them:

Icacls “foldername” /reset /c /t

Do you know how I can do this via a batch file? The end user just wants to double click it and it goes off and runs through each folder.

I suppose I need a text file with the folder names on each line?

Thanks,

Upvotes: 0

Views: 301

Answers (1)

PA.
PA.

Reputation: 29339

it's not clear if you want to run the command against all or just some of the folders.

In case you want to run the command against all of the folders in a given folder, read HELP FOR and try this in the command line

FOR /d %d in (*.*) do @echo Icacls %d /reset /c /t

change %d to %%d to include it in a batch file, test extensively, finally remove the ECHO

In case you want to run against a list of folders, then try

FOR /f %d "tokens=*" in (myfolderslist.txt) do @echo Icacls "%d" /reset /c /t

Upvotes: 1

Related Questions