I am writing a Batch-script which copies a file to multiple servers. It takes the servername from a .txt
file as a variable and uses it to connect to the server.
After a name was turned into a variable, I want to remove this entry from the file (and save it to another file) so that the Script takes the next available server name when running again.
So far, I have written this:
@echo off
:start
set /p servername=<server.txt
findstr /v "%servername%" server.txt > serverdone.txt
rem (Part of the script that copies the file, this is already working)
GOTO start
The script is able to take the first line of server.txt
and puts it in the %servername%
variable as supposed, however, the findstr
line does not seem to work. The serverdone.txt
file stays empty, and the script just keeps using the first server in the server.txt
file. I used this question as a guide: Delete certain lines in a txt file via a batch file.