user173973
user173973

Reputation:

dos batch string manipulation

I'm trying to write some dos batch script for manipulating some paths. I haven't done this in years so I might be rusty.

The path is relative and given from the command line as argument

@echo off
set wpath=%1
@echo.%wpath%
set newpath=%wpath:~0,-4%
@echo.%newpath%

The thing I'm trying to accomplish is to get rid of the extension

script.bat whatever/test.txt
whatever/test.txt
whatever/test

But I'm getting

script.bat whatever/test.txt
whatever/test.txt
<emptyline>

I'm using dosemu-1.4.0.1/DOSBox-0.74 and this as a reference

Upvotes: 2

Views: 4101

Answers (2)

user173973
user173973

Reputation:

Apparently those are wimcmd extensions and not to be found in DOS, if anyone still gets here :)

Upvotes: 2

jeb
jeb

Reputation: 82267

You could check the limits of dosemu, can it handle
echo %path:~0,4% (only positives) than you only need to get the string length
or you can try
for %%A in ("%path%") do echo %%~dpnA

Upvotes: 2

Related Questions