1

I have an Input.txt file which contains the absolute address:

I am running the batch file from this directory: "D:\FINAL\FINAL_3\mybatch.bat" The Input.txt is present in: "D:\FINAL\FINAL_3\Input.txt"

Input.txt:

D:\FINAL\FINAL_3\xx\yy\User\src\abc.c D:\FINAL\FINAL_3\qq\ww\src\def.c

Output_Template.txt

Line 1: BLA BLA BLA
Line 2: BLA BLA BLA
Line N: BLA BLA BLA

RelativeFile = File =

Line 1: BLA BLA BLA
Line 2: BLA BLA BLA
Line N: BLA BLA BLA

Now, I need to create a new Output.txt file using the information present in Input.txt, and Output_Template.txt:

Output.txt

Line 1: BLA BLA BLA
Line 2: BLA BLA BLA
Line N: BLA BLA BLA

RelativeFile = .\xx\yy\User\src\abc.c
File = D:\FINAL\FINAL_3\xx\yy\User\src\abc.c
RelativeFile = .\qq\ww\src\def.c
File = D:\FINAL\FINAL_3\qq\ww\src\def.c

Line 1: BLA BLA BLA
Line 2: BLA BLA BLA
Line N: BLA BLA BLA

What I'am doing is:
Reading the contents of Input.txt and writing it into Output.txt

for /f "tokens=* delims= " %%a in (%CD%\Input.txt) do (
echo FILE=%%a >> %file_name%
)

this is only printing:

File = D:\FINAL\FINAL_3\xx\yy\User\src\abc.c
File = D:\FINAL\FINAL_3\qq\ww\src\def.c

SeanC
  • 15,067
  • 5
  • 42
  • 63
Jatin
  • 1,663
  • 4
  • 20
  • 33

1 Answers1

2

Your script isn't even reading the template. Is it possible to use two templates, one for everything above the file paths and one for everything below? That will make combining them with the file paths much easier.

To get the relative path, you might be able to use tilde (~) syntax to extract what you need from the %%a variable. See this question.

Community
  • 1
  • 1
Spyder
  • 1,824
  • 14
  • 23