0

in a batch I have

echo VirtualDub.video.AddComment^(0x0000000C,"","%tc%"^)^;>>v:\automazioneclip\virtualdubmod\temp\%%~na.vcf

but now in place of %tc% I would like insert the contents of a text file, all content of a text file

How I have to modify it? thanks

unclemeat
  • 5,029
  • 5
  • 28
  • 52
  • What if there are multiple lines in the text file? Is it OK for a string in your function call to span multiple lines? – dbenham May 18 '14 at 22:29

2 Answers2

1

Use SET /P to print out the first portion of the line without a newline. Then use TYPE to print out the contents. Then finish up with a normal ECHO.

<nul (
  set /p ^"=VirtualDub.video.AddComment^(0x0000000C,"",""
  type file.txt
  (echo ^"^);)
) >>"v:\automazioneclip\virtualdubmod\temp\%%~na.vcf"

Note that the closing quote after the file contents will appear on the next line if the file ends with a newline. Obviously the value will be spread across multiple lines if the file contains multiple lines. Multiple lines may or may not be a problem depending on the language of the code you are writing.

dbenham
  • 127,446
  • 28
  • 251
  • 390
0

Related question: How do you loop through each line in a text file using a windows batch file?

So possibly something like:

for /F "tokens=*" %%A in (myfile.txt) do [process] %%A

where "process" is your line above.

for /F "tokens=*" %%A in (myfile.txt) do echo VirtualDub.video.AddComment^(0x0000000C,"","%%A"^)^;>>v:\automazioneclip\virtualdubmod\temp\%%~na.vcf
Community
  • 1
  • 1
Yeraze
  • 3,269
  • 4
  • 28
  • 42