Can anyone write this out?

edit..

read this bit,,


In the batch file, you'll notice that the command on the fifth line is extremely long. I've enabled Word Wrap in Notepad in order to display it all in the screen shot. This command line actually consists of three For..In..Do structures. Two of them are nested inside the Do portion of the other run Dsquery commands, and they're chained together with the Dsmove command. The shell of this command line would look like this:

For..In..Do(For..In (Dsquery) Do.. & For..In (Dsquery) Do.. & Dsmove) &..
 
Last edited:
I understand that. Can anyone attempt to write it out as my one does not work, the command prompt window just flashes up on screen
 
This is what it looks like to me.

I have no idea about whether what I've written below could even possibly be 'right' - I've just written down what it 'looks' like as best I can make out.

Feel free to correct anything that is blatantly wrong.

@echo off
cls
echo Move User Accounts
echo ------------------
For /f "tokens-1-2 delims-," %%A in (accounts.txt) do (For /f "tokens-*" %%C in ('dsquery user-name "%%A"') do (@echo moving: %%C) & For /f "tokens-*" %%D in ('dsquery ou -name "%%B"') do (@echo To : %%D) & dsmove %%C =newparent %%D) & echo ===============
pause
 
Cheers Guys, I noticed an extra set of single quotes on yours which I had missed out when copying mine so I added those into mine and it works perfectly. Had to modify values and parts to make it match my environment but it's great now!
 
Back
Top Bottom