I need to find 'errorlog105697.txt' (the random numbers are to make sure there is only ONE errorlog105697 in the entire hard drive) and then move it to the path that the batch program is in. If errorlog105697.txt is already in the same location then use: set errorcode=1
And that's all.
FYI if it has multiple errorlog105697 then set errorcode to 2
BTW I already tested if errorlog105697 exists earlier in the script. So this is what is done if it does NOT exist in the same location.
if exist errorlog105697.txt set errorcode=1 dir /s errorlog105697.txt > List.txt find /n "errorlog105697.txt" List.txt > LineNums.txtI'm not that familiar with the SET parsing commands, but here's what you need to do:
If the number of records in LineNums.txt is > 3 then set errorcode = 2
LineNums.txt contains all the line numbers where the string "errorlog105697.txt" is found in List.txt. Subtract 2 from each of these line numbers to get the line numbers that contain the directory(s) where errorlog105697.txt can be found. Extract the path information from List.txt into environment variable "MyPath". Then:
copy %MyPath%errorlog105697.txtYou'll have to decide what to do if it is both in the current directory and someplace else.
| « I need to compare a uniqu... | [Solved] Help with vars in batch? » |