Link to home
Start Free TrialLog in
Avatar of Perkentha1
Perkentha1

asked on

File Manipulation with Batch files

Currently I have ...

dir "Documents and Settings" /b %1 > c:\test.txt

dumps local profiles to a txt file.
User1
User2
User3
User4


I need to have them as a variable to perform aditional tasks.

How can this be performed?
Avatar of Lee W, MVP
Lee W, MVP
Flag of United States of America image

For /f "tokens=1" %%a in (c:\test.txt) do (
   REM Do what you want here - reference %%a when you want to use a profile directory
)
For more information, type FOR /? at a command prompt - Basically, you're saying to cycle through the file C:\test.txt and assign the first item (delimited by default by a tab or space) to the variable %%a in each loop.
Avatar of Perkentha1
Perkentha1

ASKER

Okay now my last part is Excluding the All Users directory with comes out as "All"
I increased the points for the additional question.

Thanks for the help your above statement worked.
SOLUTION
Avatar of amit_g
amit_g
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you both for your comments,  The blank line did return an error but none-the-less I found use for the statement amit so I accredited you a potion of the kitty.

Leew thank you very much for the assistance,  I never realized you could do IF statements inside a FOR statement,  I was a little narrow minded.