Echo Changing ownership of groups from textfile
@set /P filename=Please enter filename of group list: %=%
@set /P name1=Please enter name of owner to replace: %=%
@set /P name2=Please enter new owner name: %=%
FOR /F "delims=~" %%f in (%filename%) DO dsquery group -samid "%%f" | dsget group -desc>>temp1.txt
sed "s/%name1%/%name2%/g" temp1.txt>>temp2.txt
sed "/desc/d" temp2.txt>>temp3.txt
sed "/dsget succeeded/d" temp3.txt>>newownership.txt
What this program have to do is changing all names at description of group at AD....The list of groups is given in text file of your choice (filename variable)...the string to replace is in name1 var...name2 is new name.
I have found "sed" command for windows..so batch creates succesfully newownership.txt with modified descriptions of all groups (string name1 is repleced by name2 string).
And now starts the tricky part...
I need to make For loop and dunno how, because it should use two variables.I will explain what I want to achieve.
FOR /F "delims=~" %%f in (%filename%) AND %%g in (newownership.txt) DO dsquery group -samid "%%f" |dsmod group -desc "%%g"
So I need a loop to take line by line from one txt file into variable (for example %%f) and also to take line by line from newownership.txt file as a variable, and to put both into syntax which will change old description of (%%f) group to the new group description (%%g).
Is it possible to do that in DOS?