Hi! I'm working on a batch file in MS-DOS 6.21.
I'm wondering if it's possible to write a batch file that will change the first directory name in a path string.
Here's an example of what I'm trying to do:
E:\PROJECT.DIR\DRAFT1\PROJECT.TXT
A:\PROJECT.BK1\DRAFT1\PROJECT.TXT
I've figured out how to change the Drive name, e.g. changing "E:\" to "A:". That was easy, because it's just the first three characters in the string.
But is it possible to search a string for the name of that first directory in the string and then change the three letter extension between the "dot" and the second "\"?
Will in Seattle
a.k.a. "Clueless"
Can a batch file in my old version of DOS pull off that trick? Or am I going to have to dig out my old version of BASIC for DOS and try to remember how to write programs with it?
Change directory in path string?
Moderator: DosItHelp
-
- Posts: 47
- Joined: 01 Jul 2011 13:37
Re: Change directory in path string?
Since posting the above query I've played around with the macro language in my old DOS text editor, and it looks like I may be able to accomplish the task in the text editor and then pass the modified path string to my batch file from there.
I'll let you know if that works.
Will in Seattle
a.k.a. "Clueless"
I'll let you know if that works.
Will in Seattle
a.k.a. "Clueless"
Re: Change directory in path string?
You can use SED for dos to manipulate a string. Or Qbasic.
If you need help with them then reply again.
If you need help with them then reply again.
-
- Posts: 47
- Joined: 01 Jul 2011 13:37
Re: Change directory in path string?
Thanks foxidrive!
I'm an old guy and my memory is failing on me.
It's been a while since I wrote any serious batch files or BASIC programs, so I couldn't remember if there were any batch commands for manipulating strings. I'm afraid those old BASIC commands got mixed up in my memory with batch file commands.
As it turns out, it looks like the macro language built into my text editor will work for putting together modified path strings and then passing them on to a batch file.
So that's the approach I'm taking, and so far it's working out pretty well.
Thanks again,
Will in Seattle
a.k.a. "Clueless"
I'm an old guy and my memory is failing on me.
It's been a while since I wrote any serious batch files or BASIC programs, so I couldn't remember if there were any batch commands for manipulating strings. I'm afraid those old BASIC commands got mixed up in my memory with batch file commands.
As it turns out, it looks like the macro language built into my text editor will work for putting together modified path strings and then passing them on to a batch file.
So that's the approach I'm taking, and so far it's working out pretty well.
Thanks again,
Will in Seattle
a.k.a. "Clueless"
Re: Change directory in path string?
Clueless in Seattle wrote:As it turns out, it looks like the macro language built into my text editor will work for putting together modified path strings and then passing them on to a batch file.
So that's the approach I'm taking, and so far it's working out pretty well.
That's good.
-
- Posts: 21
- Joined: 19 Jul 2013 11:35
- Location: Brazil
Re: Change directory in path string?
About your question Clueless in Seattle, I understood like this:
Try this:
Create variable called MyPath
set MyPath=E:\PROJECT.DIR\DRAFT1\PROJECT.TXT [ENTER]
echo %MyPath% [ENTER]
It shows "E:\PROJECT.DIR\DRAFT1\PROJECT.TXT" on the screen
After that, hit this
echo %MyPath:~1% [ENTER]
It shows ":\PROJECT.DIR\DRAFT1\PROJECT.TXT" on the screen
So, In my opinion just put letter A
echo A%MyPath:~1% [ENTER]
It shows "A:\PROJECT.DIR\DRAFT1\PROJECT.TXT" on the screen
See you
Try this:
Create variable called MyPath
set MyPath=E:\PROJECT.DIR\DRAFT1\PROJECT.TXT [ENTER]
echo %MyPath% [ENTER]
It shows "E:\PROJECT.DIR\DRAFT1\PROJECT.TXT" on the screen
After that, hit this
echo %MyPath:~1% [ENTER]
It shows ":\PROJECT.DIR\DRAFT1\PROJECT.TXT" on the screen
So, In my opinion just put letter A
echo A%MyPath:~1% [ENTER]
It shows "A:\PROJECT.DIR\DRAFT1\PROJECT.TXT" on the screen
See you