-1

So here is what I need , I have two files , the first one is this: 1)

set idVendor=3edd

In the second file is this: 2)

   write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idVendor %idVendor%
write /sys/class/android_usb/android0/idProduct 4EE2
write /sys/class/android_usb/android0/functions mtp,adb
write /sys/class/android_usb/android0/iManufacturer ${ro.product.manufacturer}
write /sys/class/android_usb/android0/iProduct ${ro.product.model}
write /sys/class/android_usb/android0/iSerial ${ro.serialno}

So I want to replace %idVendor% with 3edd , but in the other file

NOTE: the other file is not a bat file

4

2 回答 2

0

If you are not concerned about retaining spaces in the result, you could simply use cmd to interpret the replacement.

C:>type file1.bat
SET "idVendor=3edd"

FOR /F "usebackq tokens=*" %%s IN (`TYPE file2.txt`) DO (
    CMD /C ECHO %%s
)
于 2016-03-29T12:45:50.263 回答
0

The answer that I was looking for was this

@echo off &setlocal
set "search=%~1"
set "replace=%~2"
set "textfile=Input.txt"
set "newfile=Output.txt"
call repl.bat "%search%" "%replace%" L < "%textfile%" >"%newfile%"
del "%textfile%"
rename "%newfile%" "%textfile%"

So thanks to myself I think lol :D

于 2016-03-29T20:47:58.523 回答