Generate logs of commands for the content of the text file (txt). And direct them command output to a log file in which the name is formed dynamically.
Users.txt file:
Code: Select all
sp\alonso;contoso\12345678
ac\willian;contoso\87654321
rj\ronda;contoso\78662223
I'm in my house, and thinking of a script to run at work tomorrow.
I imagined a code:
Code: Select all
@echo off
SET SERVER=google
SET TXT=users.txt
SET log=%SERVER%_process.log
cd /d "C:\" rem incomplete
for /F "tokens=1,2 delims=;" %%a in (%TXT%) do (
for /F "delims=" %%c in ('stsadm -o migrateuser -oldlogin %%a -newlogin %%b -ignoresidhistory ^> "%%a-%%b.log"') do echo %%c >> %log%
)
ECHO Bye!
The code will generate a fixed name for a file. To generate the other files variable names, for example:
Code: Select all
sp_alonso-contoso_12345678.log
ac_willian-contoso_87654321.log
rj_ronda-contoso_78662223.log
google_process.log
Before, you must treat the variables _a and _b, and then replace the slash (\) by underscore (_).
Help me with the code. So that there is failure in the code.