1.

Solve : batch for using 2 txt files?

Answer»

I am trying to make a batch FILE which will take a comand line from text file and computer name to execute command.
But all what I succed is to take text from first file.

In first.txt I have this line
first.txt
copy /Y \\server1\USERS\%computername%\john\deltmp.txt c:\logs\deltmp.txt

copy.bat
Echo %computername%>>C:\Users\Admin\test\computername.txt
for /f "delims=" %%a in (C:\Users\Admin\test\first.txt) do %%a


When I execute copy.bat I get error
The system cannot find the path specified.
        0 file(s) copied.

because variable %computername% is not recognised from first.txt file
how to read computername so batch will copy that file.
I have CREATED a file computername.txt to read from that file but don't know how to implement that in batch.

And I need it separately batch and first.txt file, because first.txt changes as neededI found a solution with fart
https://sourceforge.net/projects/fart-it/
small program for find and replace Glad you found the answer that WORKS for you.
The fart.exe is a program based on UNIX stuff. It is like grep, a standard UNIX utility.

Windows users might prefer to use Powershell instead.
Look at this post about fart:
HTTP://lifehacker.com/354546/find-and-replace-text-with-fart
Notice the third comment:
Quote

why waste time on this when you got powershell?
to do a search:
select-string {pattern} {filename}
to do a replace:
$content = get-content {filename}
$content -creplace "searchtext","replacetext" | set-content {filename}
regular expressions are supported in search patterns.
you do this and so much more. Powershell rules.
Powershell Tutorials are available.
https://mva.microsoft.com/en-us/training-courses/getting-started-with-powershell-3-0-jump-start-8276


Discussion

No Comment Found