[windows2000] Re: Batch for in-loops

  • From: "Sorin Srbu" <sorin.srbu@xxxxxxxxxxxxx>
  • To: <windows2000@xxxxxxxxxxxxx>
  • Date: Fri, 5 Sep 2008 12:08:54 +0200

Sorin Srbu <> scribbled on Friday, September 05, 2008 12:01 PM:

Turns out I missed two critical things... Command should be as follows:

For /f %A in (users.txt) fo chown -v -q %A %A

"/f" apparantely tells the for-statement to look in a file.

I've got to remember this for the future use...

> I can't get this to work...
> Had a fileserver fail a disk in a raid, fixed it and all files are now
> transferred back from backup. All files are owned by Administrator which
> kinda' messes up the quotas.
> So, I found this tool, called chown and it works well, only I have some
> 120ish homefolders I need to change the owner on.
> I figured I could do a for in batch-loop and I can't make it work. What I've
> done so far:
> * created a simple text file, users.txy, with all the folders I want
> changed. All folders have the same name as the user in question.
> * on a command line I typed "for %A in users.txt do chown -v -q %A %A" and
> ran it. Got an error "users.txt was unexpected at this time".
>       Ie for folder User1 use CLI-tool chown to change the folder User1 to
> owned by User1 and do it quietly and verbosely in case a fatal error
> happens. 
> What gives? I do believe I've done this before. Did I mix up the order on
> the command line?
> TIA.

Other related posts: