You can write a for loop which loops through directory names with the /d switch,
for /d %A in (e:\FTP_Root\user*) do (
icacls "%A\*" /q /c /t /reset
)
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,
@echo icacls "%A\*" /q /c /t /reset
Here it is on one line, for clarity.
for /d %A in (e:\FTP_Root\user*) do icacls "%A\*" /q /c /t /reset
Here's a wee test, given the file tree below
E:\FTP_ROOT
|
+---user1
| bar.txt
| baz.txt
| foo.txt
|
+---user2
| bar.txt
| baz.txt
| foo.txt
|
\---user3
bar.txt
baz.txt
foo.txt
C:\>for /d %A in (e:\FTP_Root\user*) do icacls "%A\*" /q /c /t /reset
C:\>icacls "e:\FTP_Root\user1\*" /q /c /t /reset
Successfully processed 3 files; Failed processing 0 files
C:\>icacls "e:\FTP_Root\user2\*" /q /c /t /reset
Successfully processed 3 files; Failed processing 0 files
C:\>icacls "e:\FTP_Root\user3\*" /q /c /t /reset
Successfully processed 3 files; Failed processing 0 files
You can always add the @echo
after the do
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:
for /d %%A in (e:\FTP_Root\user*) do icacls "%%A\*" /q /c /t /reset