April 4, 200917 yr 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,2kdcom.dll = 1,,,,,,3_,2,0,0,,1,2c_1252.nls = 1,,,,,,3_,2,0,0,,1,2c_437.nls = 1,,,,,,3_,2,0,0,,1,2and i want add under the [sourceDisksFiles] this new string,example.dll = 1,,,,,,3_,2,0,0,,1,2and result must like this[SourceDisksFiles]example.dll = 1,,,,,,3_,2,0,0,,1,2bootvid.dll = 1,,,,,,3_,2,0,0,,1,2kdcom.dll = 1,,,,,,3_,2,0,0,,1,2c_1252.nls = 1,,,,,,3_,2,0,0,,1,2c_437.nls = 1,,,,,,3_,2,0,0,,1,2How can i do bat or cmd script for this? Thanx for answers...
April 4, 200917 yr You need to create a new temporary file (that you can later rename as TXTSETUP.SIFSomething like this:If exist new.sif del new.sifFOR /F "tokens=* delims=" %%A IN (TXTSETUP.SIF) DO (IF "%%A"=="[SourceDisksFiles]" (ECHO [SourceDisksFiles]>>new.sifECHO 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
April 4, 200917 yr Author You need to create a new temporary file (that you can later rename as TXTSETUP.SIFSomething like this:If exist new.sif del new.sifFOR /F "tokens=* delims=" %%A IN (TXTSETUP.SIF) DO (IF "%%A"=="[SourceDisksFiles]" (ECHO [SourceDisksFiles]>>new.sifECHO 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.jaclazIts work thanx, but have a fix, ECHO example.dll = 1,,,,,,3_,2,0,0,,1,2>>new.sifLeave a space beetween 0,,1,2 and >>new.sifThanx, working this..
April 4, 200917 yr Leave a space beetween 0,,1,2 and >>new.sifThanx, working this..Yep , my bad , 2>>new.sif (without space before the >>) will be interpreted as a redirection:http://www.robvanderwoude.com/redirection.phpjaclaz
April 6, 200917 yr 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,2kdcom.dll = 1,,,,,,3_,2,0,0,,1,2c_1252.nls = 1,,,,,,3_,2,0,0,,1,2c_437.nls = 1,,,,,,3_,2,0,0,,1,2You 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 $inputecho $input >> $output# Write file back.echo $output > "txtsetup.sif"biterscripting scripting or batch language is free at http://www.biterscripting.com . Sen Edited April 6, 200917 yr by SenHu
April 6, 200917 yr biterscripting scripting or batch language is free at http://www.biterscripting.com .I doubt about it being "Free". 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.htmlWith 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
April 6, 200917 yr Author 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.cmdim run cmd file but createtext.cmd content is thisecho example textWheras i want output like thisecho example text>>abcd.txtWhat is delimiter character on dos ?Thanks for answers...
April 7, 200917 yr You need to "escape" special characters.Try with:echo echo example text^>^>abcd.txt>>createtext.cmdjaclaz
April 7, 200917 yr Author You need to "escape" special characters.Try with:echo echo example text^>^>abcd.txt>>createtext.cmdjaclazAh its working, jaclaz thanks for code, youre very good on dos, im to try with backslah like a php but unsuccess...
April 8, 200917 yr 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
Create an account or sign in to comment