I have a .batch script in my Send to folder on Windows which I use to compress multiple files in the folder to a .zip. The problem I'm having is, it's including the extension in the archive file name.
I've search on google, read a lot of posts on stackexchange etc and none of the solutions posted seem to work for me.
@echo off
for %%A in (*.*) do call :doit "%%A"
goto end
:doit
if "%~x1"==".bat" goto :eof
if "%~x1"==".7z" goto :eof
if "%~x1"==".zip" goto :eof
if "%~x1"==".rar" goto :eof
"C:\Program Files\7-Zip\7z.exe" a -tzip %1.zip %1 -sdel
goto :eof
:end
Myfile.txt -> MyFile.txt.zip
I want to remove the .txt from file name if possible.
%1
is your full filename, then%~n1
is the name,%~x1
is the extension etc. Seecall /?
for a full list of possibilities. – Stephan