<p>Is there a way to take substrings of a string with .bat/.cmd files?</p>

<p>For example given the string "hello.txt" is there a way to strip the .txt?</p>

<p>EDIT: Also is there a more general way to do this, not under the assumption that it is a file name or file path?</p>

If this is a file passed as a parameter, you can use %~n1, like this:
```
```
test.bat
----------
echo %~n1 %~n2

c:\> test.bat myfile.txt my.long.file.bat
  myfile my.long.file
```
```
If you know the length of the string you can use the substring operator:
```
```
echo %variable:0,4%   =>  "test.txt" => "test"
```
```
And to get everything EXCEPT the last 4 characters:
```
```
echo %variable:~0,-4%  => "file...name.txt" => "file...name"
```
```
BatchFiles Website (kind advanced)
Decent forum post
Another Good Post