help with loading an file!!

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
rasil
Posts: 6
Joined: 23 Apr 2020 13:05

help with loading an file!!

#1 Post by rasil » 31 Jul 2020 04:40

hello everyone!!

so i want to make a batch file with a batch file.

the file that is going to make a batch file is called (A.bat)

the file that is going to be made is called (B.bat)

so here is the code to *A.bat*
-----------------------------------------------------------------------------------------------------
@echo off
:start
(for /f "tokens=* delims=:" %%L in ('findstr /b ::: "%~f0"') do echo %%L) >B.bat

::: @echo off
::: color f0
::: echo hello
::: pause
-------------------------------------------------------------------------------------------------------

but here is the problem see this code
::: @echo off
::: color f0
::: echo hello
::: pause

i do not want that i want the program to load that code from another file which is going to be called(Package.txt)

so for example *package.txt will have this code:
::: @echo off
::: color f0
::: echo hello
::: pause

and i just run *A.bat* and it will take the code form *package.txt* and create a batch file called *B.bat* :)

thanks for reading and have a nice day, any help would be appreciated!!! :D

Squashman
Expert
Posts: 4198
Joined: 23 Dec 2011 13:59

Re: help with loading an file!!

#2 Post by Squashman » 31 Jul 2020 08:40

So what is stopping you from reading package.txt instead of the batch file?

rasil
Posts: 6
Joined: 23 Apr 2020 13:05

Re: help with loading an file!!

#3 Post by rasil » 31 Jul 2020 10:09

thanks for replaying!

I just want to have a batch file and a package.txt file when i run the batch file there should be a batch file created!

Squashman
Expert
Posts: 4198
Joined: 23 Dec 2011 13:59

Re: help with loading an file!!

#4 Post by Squashman » 31 Jul 2020 10:16

So I will ask again. What is stopping you from reading package.txt instead of the batch file to get your result?

rasil
Posts: 6
Joined: 23 Apr 2020 13:05

Re: help with loading an file!!

#5 Post by rasil » 31 Jul 2020 10:37

so what if i have a batch file and lots of programs for it then ill just put package.txt file in the same directory and the batch file and run it then i will be able to run package.txt file inside the batch file for example:

Main.bat
Main.bat has a lot of programs written for it!

(Program1.txt)
@echo off
echo this is program1!
pause

(Program2.txt)
@echo off
echo this is program2!
pause


and what i need to do it put the program1.txt in the same folder as Main.bat and it will run what was written in program1.txt!

hope this helps you understand the situation :)

Post Reply