Batch Script to list folder permissions

Microsoft Windows xp professional w/serv...
February 23, 2010 at 23:47:18
Specs: Windows XP
Hi,

I would like to write a batch script to perform the following tasks,

1) The script should ask the user to input the drive information (C:\, D:\, etc)
2) Once the user inputs the drive information, it should print all the folders (not sub-folders, only the folders) in that drive to a file.
3) Now the script should find the folder permissions for the list of folders printed in the file.
4) It should print the output to a file.

I've the script to do the steps 3 & 4. But currently it will work only on the folder you specify. I want to have this done for all the folders in a drive.

@echo off
set target=C:\test
cacls "%target%" > c:\list.txt
for /F "tokens=*" %%* in ('dir /b /ad "%Target%"') do cacls "%target%%%*"


See More: Batch Script to list folder permissions

Report •


#1
February 24, 2010 at 02:21:02
If you store what is entered in "target" as e.g. "C:"

for /F "delims=" %%j in ('dir /B /AD %target%\*') do echo.%%j %%~aj >> C:\list.txt

The above statement lists all folders (%%j) with their attributes (%%~aj). If you want just the folder's name without drive letter replace %%j with %%~nxj.

Report •

#2
February 24, 2010 at 02:44:29
Hi IVO,

Thanks for ur kind response,

The script u provided prints the folders in the directory, but is there any way to print the folders in the directory with the path ?

For Example,

The script should prompt the user to input the drive,

so, if i input C:\

Then it should print the folders with the path (only parent folders, not the sub-folders or files) in C:\ drive in a file output1.txt like below,

C:\test1
C:\test2
C:\test3

Now the script should use the list in output1.txt and print the folder permissions for each folder in the list in to another file.

This is how i am trying to build the batch script. The current batch script which i have will print the folder permissions, if we provide the folder name with path.

@echo off
set target=C:\test
cacls "%target%" > c:\list.txt
for /F "tokens=*" %%* in ('dir /b /ad "%Target%"') do cacls "%target%%%*"

Thanks,
PK


Report •

#3
February 24, 2010 at 03:46:55
@echo off & setlocal
set /P target=Enter Drive letter (e.g. C:)^>
type nul > C:\list1.txt
cd /D %target%\
for /F "delims=" %%j in ('dir /B /AD') do echo.%%~fj >> C:\list1.txt
type nul > C:\list2.txt
for /F "delims=" %%j in (C:\list1.txt) do echo.%%j %%~aj >> C:\list2.txt
type C:\list2.txt
:: End_Of_Batch


Report •

Related Solutions

#4
September 14, 2010 at 06:06:35
i Really need this script. have too many folders and want to clean up the rights into groups. please send me the script on email and if i wanted to list subfolders where do i make the changes? god bless...

(n.b i have no clue on using scripts)
<removed>@yahoo.com

edited by moderator: Removed email address -Razor2.3


Report •


Ask Question