Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I have a simple problem. What I need to do is remove the extension from a variable such as %a (contains a filename) and put this into %b.
For example:
When %a is abc.jpg %b is abcThanks In Advance!
Stefan

This is so cool! I just guessed, but it works. Little things like this is why I like DOS so much....even in our GUI world.Just use a wildcard. Example...
rename *.doc *.txt
will change the every .doc extension of the files IN THE CURRENT DIRECTORY to a .txt extension.
LIKEWISE
rename *.doc *
will simply remove the .doc extension of every file (which has a .doc extension).
HOWEVER, be VERY, VERY careful not to remove it from files which you DO want to have it. This is a very unforgiving command. MAKE BACKUP COPIES OF THE FILES YOU PLAN TO MANIPULATE.

Here goes a more secure way:
(I'm using %a% and %b%)@echo off
set b=
if "%extout%"=="1" goto parse
set extout=1
echo ; |choice /c;%a%; %0;>out.bat
out.bat
:parse
IF "%1"=="[" SHIFT
IF "%1"=="]?" goto end
IF "%1"=="." goto end
IF NOT "%B%"=="" SET B=%B%%1
IF "%B%"=="" SET B=%1
SHIFT
GOTO parse
:end
set extout=
if exist out.bat del out.batThat's it. That weren't made by me. Laurence Soucy did it (just a little different) and I have adapted it to your case
-- Secret_Doom --

![]() |
dos
|
Adding SoundBlaster 16 to...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |