Elena Quinn
asked on
Extracting a string from another string in MS-DOS
I am trying to take an input string, extract the second through ninth character and use it as a directory name. This is real DOS I'm talking about, not a shell in Windows. This is real boot up to a C:\ prompt DOS from a Windows 98 boot disc. Windows is non-existent on this system.
I tried:
But it just returns "ECHO is on"
I want to see 23456789, so I can then use it to create a directory named 23456789.
The end goal here is to create a batch file which I can launch with the string as an argument. Then I would create a directory and take the results of the batch file and copy them into that directory. Every time I run this particular test, it will overwrite the results, so I need to move them into a meaningful directory name each time.
I tried:
set test=123456789012
echo %test:~1,9%
But it just returns "ECHO is on"
I want to see 23456789, so I can then use it to create a directory named 23456789.
The end goal here is to create a batch file which I can launch with the string as an argument. Then I would create a directory and take the results of the batch file and copy them into that directory. Every time I run this particular test, it will overwrite the results, so I need to move them into a meaningful directory name each time.
ASKER
It doesn't show as expected on my machine. As I said, this is a straight DOS environment. 'setlocal' returns a "Bad command or filename" error.
Elena
Which version of MS-DOS are you using?
You can find that out using VER at the command line.
Which version of MS-DOS are you using?
You can find that out using VER at the command line.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Solutions given.
Open in new window
...it shows as expected:
Open in new window
Maybe adding setlocal enabledelayedexpansion at the top will help you:
Open in new window