Looking to find a better way to script this for multiple folders.
Right now I have a icacls script that is reseting permissions on files/folder from a parent folder:
icacls "e:\FTP_Root\user1\*" /q /c /t /reset
icacls "e:\FTP_Root\user2\*" /q /c /t /reset
icacls "e:\FTP_Root\user3\*" /q /c /t /reset
Is there a better way to do this so I don't have to keep adding lines for new users?
Each user folder has its own permissions applied to it so anything inside the users folder gets its permissions reset to inherit from the users folder using the script above.
Best Answer
You can write a for loop which loops through directory names with the /d switch,
You can always test that the loop is going to do what you want by prepending the icacls line with an echo, which will print the command rather than executing it,
Here it is on one line, for clarity.
Here's a wee test, given the file tree below
You can always add the
@echo
after thedo
to check what the command will actually look like before running it for real.FOR loops in scripts Windows .bat/.cmd scripts require doubled
%%
with variables, whereas the shell requires just a single%
, so in a cmd shell script the loop would look like this: