VOGONS


First post, by nvm

User metadata
Rank Newbie
Rank
Newbie

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 DOSBox version 0.74 and this as a reference

Reply 1 of 5, by ripsaw8080

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Does that stuff work in real DOS? DOSBox's shell emulates MSDOS 5/6 (and only to some extent), not the Windows Command Shell.

Reply 2 of 5, by nvm

User metadata
Rank Newbie
Rank
Newbie

Have no idea, I haven't used anything but linux for the past decade. Works on XP's cmd

Any other suggestion?

Reply 3 of 5, by VileR

User metadata
Rank l33t
Rank
l33t

well, that reference site calls itself DOS Tips yet says it's "for Windows7, VISTA ,XP, NT, Server 2000, Server 2003, Server 2008".

[cue Family Guy style showtune parody - "the Windows command prompt isn't DOS, isn't DOS, isn't DOS"]

Do you need the extension-less pathname as a variable? or just want to echo it out?

[ WEB ] - [ BLOG ] - [ TUBE ] - [ CODE ]

Reply 4 of 5, by ADDiCT

User metadata
Rank Oldbie
Rank
Oldbie

Just use 4DOS, it has a number of advanced string manipulation routines.

Reply 5 of 5, by peterferrie

User metadata
Rank Oldbie
Rank
Oldbie

It works only in the Windows command-shell, because it's relying on an extension that was added in Windows XP.