Hi guys,
I have the below script that runs though folder and applies permissions to all folders, named "staff" and its content.
It does work, BUT until its gets to a folder with spaces in the name then it fails. I have thousands of folder names with spaces. Can someone please help me tweak this code to make it work?
This is my code, thank you very much.
for /F %i in ('dir F:\CurrentClients\*staff* /s /b /ad') do icacls %i /grant "SG-staff":(OI)(CI)(RX,W,AD,WA,WEA,REA) /inheritance:r
__________________________________________________________________
When doing a dir this is the output, it does pick up the correct folder:C:\Users\testpc>dir C:\CurrentClients\*staff* /s /b /ad
C:\CurrentClients\Client 3\staff
C:\CurrentClients\Client1\staff
C:\CurrentClients\Client2\staff
C:\Users\testpc>for /F %i in ('dir C:\CurrentClients\*staff* /s /b /ad')
do icacls %i /grant "domain\username":(OI)(CI)(RX,W,AD,WA,WEA,REA) /inheritance:r
C:\Users\testpc>icacls C:\CurrentClients\Client /grant "domain\uername":(OI)(CI)(RX,W,AD,WA,WEA,REA) /inheritance:r
C:\CurrentClients\Client: The system cannot find the file specified.
Successfully processed 0 files; Failed processing 1 files
C:\Users\testpc>icacls C:\CurrentClients\Client1\staff /grant "domain\username":(OI)(CI)(RX,W,AD,WA,WEA,REA) /inheritance:r
processed file: C:\CurrentClients\Client1\staff
Successfully processed 1 files; Failed processing 0 files
C:\Users\testpc>icacls C:\CurrentClients\Client2\staff /grant "domain\username":(OI)(CI)(RX,W,AD,WA,WEA,REA) /inheritance:r
processed file: C:\CurrentClients\Client2\staff
Successfully processed 1 files; Failed processing 0 files
- Edited by Lest3r Friday, July 31, 2015 9:42 AM updated