VOGONS


First post, by keropi

User metadata
Rank l33t++
Rank
l33t++

Hiya!!!
does such a program exists? Let me explain what I want to do... 😅
I am trying to make a batch file that will edit a variable in a text file , the variable depends on the location of the .bat file...

so for example if I have: c:\test\varedit.bat , it would open a file , look for a predefined string like %EDITME% and change it to C:\TEST\
I know I can get to a dos variable the current .bat file location with %~dp0 , but how to make %~dp0 replace the %EDITME% string in my file?

any pointers would be highly appreciated! 😁

🎵 🎧 MK1869, PCMIDI MPU , OrpheusII , Action Rewind , Megacard and 🎶GoldLib soundcard website

Reply 1 of 11, by ratfink

User metadata
Rank Oldbie
Rank
Oldbie

That sounds like the kind of thing that would be fairly easy to write in BASIC.

Reply 3 of 11, by Davros

User metadata
Rank l33t
Rank
l33t

i wouldnt try replacing the string
i would have 2 files 1 with editme in and 1 with c:\test in it

lets say the file containing the string you want to be called result.bat
have 2 files called result.one + result.two
and rename whatever one of those to result.bat

so if you want to have result.bat contain c:\test rename one of the two files (the one containing c:\test) to result.bat

edit: I think ive misundestood what your trying to do
you want to :

if file exist then replace string ? yes ?

IF exist Command:

IF EXIST c:\test\varedit.bat COPY c:\test\result.one c:\test\result.bat

Reply 4 of 11, by keropi

User metadata
Rank l33t++
Rank
l33t++

What I am trying to do is this:

have a file called: keropi.cfg that it has for example:

# keropi config #
keropi path=%EDITME%
blah
blah

so I have a set from before an environment variable like: SET keropipath=C:\KEROPI
and the program would grab C:\KEROPI and write it in where %EDITME% is...

ps. I think I won't find what I need unless I can code it myslef 🤣

🎵 🎧 MK1869, PCMIDI MPU , OrpheusII , Action Rewind , Megacard and 🎶GoldLib soundcard website

Reply 6 of 11, by (stolen.alias)

User metadata
Rank Newbie
Rank
Newbie

this can easily be done with a batch file, for the example you gave...

create a file c:\header.txt containing:
# keropi config #

create a file c:\footer.txt containing:
blah
blah

create a file makecfg.bat containing:
@type c:\header.txt > %1
@echo keropi_path=%EDITME% >> %1
@type c:\footer.txt >> %1

now run makecfg with parameter of the filename you want to create..
ie.. makecfg keropi.cfg

if you would rather supply the %EDITME% text on commandline you could have a makecfg.bat as:
@type c:\header.txt > %1
@echo keropi_path=%2 >> %1
@type c:\footer.txt >> %1

then run as
makecfg keropi.cfg c:\my\path
to create the file...

Reply 8 of 11, by (stolen.alias)

User metadata
Rank Newbie
Rank
Newbie

nope... will work fine under plain dos...

for example here's an old batchfile(testzips.bat) i just snagged from my old 286 running dos 3.3 that ran a node of my bbs in the early 90's, the batchfile creates and runs a second batch file (testem.bat) that runs a third batchfile (add2zip.bat) on each .zip file within the directory that was specified as a parameter to the first batchfile (was used to test .zip uploads)..

@echo off
rem run as: "testzips drive:\some\path"
rem %1 directory containing files to test
echo testing uploads (.zip ) ...
rem delete old logfile...
if exist testfile.log then del testfile.log
echo Testing files (.zip). Please wait...
rem create batch file to test each .zip file...
if exist testem.bat del testem.bat
for %%f in (%1\*.ZIP) do echo call ADD2ZIP %%f %2 %3 >>testem.bat
rem call the created batchfile
call testem.bat
rem log any failures
if exist testfile.log echo one or more files failed -- consult FAILED.LOG...
type testfile.log >> failed.log

Reply 10 of 11, by elianda

User metadata
Rank l33t
Rank
l33t

I'd just want to mention that the classic edlin editor that comes with dos is fully remote controllable by piping in the commands.
And its damn fast aswell.

Retronn.de - Vintage Hardware Gallery, Drivers, Guides, Videos. Now with file search
Youtube Channel
FTP Server - Driver Archive and more
DVI2PCIe alignment and 2D image quality measurement tool

Reply 11 of 11, by Varka

User metadata
Rank Newbie
Rank
Newbie

edlin

Great. Back to therapy I go.