0

So, in this code i have a variable filename that have a string that is a filename: blank.txt, and i'm trying to separate it in two sections: witfilename -> Filename without the extension, and the extension -> the extension of the filename.

The code:

::Complete filename.
set filename=blank.txt
:: Filename without the '.extension' (doesn't work)
set witfilename=%name:.*=%
:: File-extension only. (it works!)
set extension=%filename:*.=%
 
::Print the values
echo name: %filename%
echo witname: %witfilename%
echo extension: %extension%

----------

Output:

name: blank.txt
witname: blank.txt <- problem here (should be: 'blank' only)
extension: txt

The output of %witfilename% is the entire filename, but what i'm trying to get is everything after the dot (to remove of course, so is to keep everything before the dot blank). I think the problem is the *= together because the * i already used in extension without any problems, but i think it's *= together since it's basically a math operation in most of programming languages and is in batch too??? i read about that operands in batch but it's weird and don't worked when i tried.

Nazzel
  • 31
  • 6

0 Answers0