Hello,
I am writing a batch file to set user permissions for a plethora of folders. For one specific folder, I would like to set different permissions for each directory and sub-directory. The issue I'm having is getting to a certain level and setting permissions for all those folders. Example:
Main folder > (20 Folders in Main Folder) > (50 Folders in each sub-Main Folder) > (5 folders after that) > pdf files
The numbers are arbitrary, but that's somewhat how the construction of our file system looks like.
the directory right before the pdf files (5 folders after that) should have modify permissions. each sub-folder before that should have only folder creation permissions. Finally, the Main folder has read-only permissions.
What I have attempted so far is this batch script:
icacls "Main Folder" /grant:r %username%:M /T
FOR /D %%S in ("Main Folder\*") do icacls "%%S" /grant:r Users:(R, AD) /grant:r %username%:(R, AD)
icacls "Main Folder" /grant:r Users:R /grant:r %username%:R
This sets the permissions I want but only up to this point: Main folder > (20 Folders in Main Folder) > (50 Folders in each sub-Main Folder)
I've tried nesting a FOR loop to get into that last directory, but had no success.
Thank you!
Can you get a list of the right ones using
Dir main folder\sub folder\*\ /ad /b or with 5 x \* if it is 5 folders deeper?
Steve