| 1. |
Solve : Batch file to split a string into multiple strings? |
|
Answer» Hi. I need a script that will take a string and split it up by " %% " with no quotes. It would be very easy if you could output them on different lines (displayed). Thank you, but it just says "Echo is off". I ran this batch file... Code: [Select]@echo off echo MyString=wscript.arguments(0)>splitter.vbs echo MyArray = Split(MyString, "%%%%", -1, 1)>>splitter.vbs echo last=UBound(MyArray)>>splitter.vbs echo For j = 0 To last>>splitter.vbs echo wscript.echo MyArray(j)>>splitter.vbs echo Next>>splitter.vbs set Longstring=Cat%%%%Dog%%%%Horse%%%%Bird%%%%Fish%%%%Chicken echo Longstring=%Longstring% for /f "delims=" %%A in ( 'cscript //nologo splitter.vbs "%Longstring%" ' ) do echo %%A del splitter.vbs and this was the output... Code: [Select]Longstring=Cat%%Dog%%Horse%%Bird%%Fish%%Chicken Cat Dog Horse Bird Fish Chicken If you will show me the code you have used I will try to advise. Where are you getting the long string from? It changed on me. Now it is working. But one problem. I am getting the longstring from a file that I know exists (I entered the path in windows explorer) but it says the file is not found. Any ideas?Quote from: flytothemoon on June 11, 2010, 02:22:11 PM Any ideas? Be thorough and careful and check what you are doing. |
|