elmor Posted April 4, 2009 Share Posted April 4, 2009 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... Link to comment Share on other sites More sharing options...
jaclaz Posted April 4, 2009 Share Posted April 4, 2009 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 Link to comment Share on other sites More sharing options...
elmor Posted April 4, 2009 Author Share Posted April 4, 2009 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.. Link to comment Share on other sites More sharing options...
jaclaz Posted April 4, 2009 Share Posted April 4, 2009 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 Link to comment Share on other sites More sharing options...
SenHu Posted April 6, 2009 Share Posted April 6, 2009 (edited) 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, 2009 by SenHu Link to comment Share on other sites More sharing options...
jaclaz Posted April 6, 2009 Share Posted April 6, 2009 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 Link to comment Share on other sites More sharing options...
elmor Posted April 6, 2009 Author Share Posted April 6, 2009 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... Link to comment Share on other sites More sharing options...
jaclaz Posted April 7, 2009 Share Posted April 7, 2009 You need to "escape" special characters.Try with:echo echo example text^>^>abcd.txt>>createtext.cmdjaclaz Link to comment Share on other sites More sharing options...
elmor Posted April 7, 2009 Author Share Posted April 7, 2009 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... Link to comment Share on other sites More sharing options...
Yzöwl Posted April 7, 2009 Share Posted April 7, 2009 youre very good on dosIt's not DOS! It's the Windows NT Command Shell. Link to comment Share on other sites More sharing options...
DarkShadows Posted April 8, 2009 Share Posted April 8, 2009 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now