Jump to content

Inserting new string txtsetup.sif with batch script


Recommended Posts

I want insert new string in txtsetup.sif with batch script.

Example: this txtsetup.sif content,

[SourceDisksFiles]
bootvid.dll = 1,,,,,,3_,2,0,0,,1,2
kdcom.dll = 1,,,,,,3_,2,0,0,,1,2
c_1252.nls = 1,,,,,,3_,2,0,0,,1,2
c_437.nls = 1,,,,,,3_,2,0,0,,1,2

and i want add under the [sourceDisksFiles] this new string,

example.dll = 1,,,,,,3_,2,0,0,,1,2

and result must like this

[SourceDisksFiles]
example.dll = 1,,,,,,3_,2,0,0,,1,2
bootvid.dll = 1,,,,,,3_,2,0,0,,1,2
kdcom.dll = 1,,,,,,3_,2,0,0,,1,2
c_1252.nls = 1,,,,,,3_,2,0,0,,1,2
c_437.nls = 1,,,,,,3_,2,0,0,,1,2

How can i do bat or cmd script for this? Thanx for answers...

Link to comment
Share on other sites


You need to create a new temporary file (that you can later rename as TXTSETUP.SIF

Something like this:

If exist new.sif del new.sif
FOR /F "tokens=* delims=" %%A IN (TXTSETUP.SIF) DO (
IF "%%A"=="[SourceDisksFiles]" (
ECHO [SourceDisksFiles]>>new.sif
ECHO example.dll = 1,,,,,,3_,2,0,0,,1,2>>new.sif
) ELSE (
ECHO %%A>>new.sif
)
)

Should do.

Otherwise you could use an external program like gsar:

http://home.online.no/~tjaberg/

Or any other search and replace utilities.

jaclaz

Link to comment
Share on other sites

You need to create a new temporary file (that you can later rename as TXTSETUP.SIF

Something like this:

If exist new.sif del new.sif
FOR /F "tokens=* delims=" %%A IN (TXTSETUP.SIF) DO (
IF "%%A"=="[SourceDisksFiles]" (
ECHO [SourceDisksFiles]>>new.sif
ECHO example.dll = 1,,,,,,3_,2,0,0,,1,2>>new.sif
) ELSE (
ECHO %%A>>new.sif
)
)

Should do.

Otherwise you could use an external program like gsar:

http://home.online.no/~tjaberg/

Or any other search and replace utilities.

jaclaz

Its work thanx, but have a fix,

ECHO example.dll = 1,,,,,,3_,2,0,0,,1,2>>new.sif

Leave a space beetween 0,,1,2 and >>new.sif

Thanx, working this..

Link to comment
Share on other sites

Good suggestions and code so far. Here is an alternate way.

Your txtsetup.sif file looks like this.

[sourceDisksFiles]

bootvid.dll = 1,,,,,,3_,2,0,0,,1,2

kdcom.dll = 1,,,,,,3_,2,0,0,,1,2

c_1252.nls = 1,,,,,,3_,2,0,0,,1,2

c_437.nls = 1,,,,,,3_,2,0,0,,1,2

You want to insert the line "example.dll = 1,,,,,,3_,2,0,0,,1,2" right after the line "[sourceDisksFiles]" using a batch script.

Here is a biterscript (biterscripting script).

var str input, output; cat "txtsetup.sif" > $input
# Extract everything upto "[SourceDisksFiles]\n"
stex "^[SourceDisksFiles]\n^]" $input > $output
# Add "example.dll = 1,,,,,,3_,2,0,0,,1,2\n"
echo "example.dll = 1,,,,,,3_,2,0,0,,1,2\n" >> $output
# Add remaining portion of $input
echo $input >> $output
# Write file back.
echo $output > "txtsetup.sif"

biterscripting scripting or batch language is free at http://www.biterscripting.com .

Sen

Edited by SenHu
Link to comment
Share on other sites

biterscripting scripting or batch language is free at http://www.biterscripting.com .

I doubt about it being "Free". :unsure:

It may be "Free as in free beer" but definitely NOT "Free as in freedom".

Basically one should download and install an unknown program from the internet, allowing it to by-pass firewall in order to get a serial number, the Agreement is shown AFTER the program has connected to the Server, and then we have something that is hardcoded to C:\biterScripting (please note that Windows uses backslash "\" and not forward slash "/" in paths):

http://www.biterscripting.com/install.html

:w00t:

With all due respect, there isn't a single word (even a "fake" one ) about WHO actually biterScripting.com is, the reason WHY it produced this scripting language, WHY it is giving it away for free, WHY it needs a connection and an online serial number, WHAT are the contents of the License Agreement, WHERE it is based, No e-mail, NO telephone number, NO hints about the Author(s).

It would be interesting if you could provide some of the info above. :)

jaclaz

Link to comment
Share on other sites

Well, i have another problem now, i want create with new file with cdm file :)

My cmd file content

echo echo example text>>abcd.txt>>createtext.cmd

im run cmd file but createtext.cmd content is this

echo example text

Wheras i want output like this

echo example text>>abcd.txt

What is delimiter character on dos ?

Thanks for answers...

Link to comment
Share on other sites

You need to "escape" special characters.

Try with:

echo echo example text^>^>abcd.txt>>createtext.cmd

jaclaz

Ah its working, jaclaz thanks for code, youre very good on dos, im to try with backslah like a php :P but unsuccess...

Link to comment
Share on other sites

It's not DOS! It's the Windows NT Command Shell.

Bah, Humbug! The command syntax looks like MS-DOS, acts like MS-DOS, even has some of the same bugs as MS-DOS. (Although, it does have some newer and more inventive bugs than MS-DOS did.) I'll bet they kept 90% or more of the code exactly the same as it was for MS-DOS, when they tucked it up inside Windows. However, it is true that it is no longer a Disk Operating System, and in that regard, it truly is not DOS.

Just ruffling your feathers Yzöwl :lol:

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...