@echo off

if exist "c:\Program Files\7-Zip\7z.exe" (
    echo  file 7z.exe application exists



) else (
    echo  file doesn't exist and will need to create it to allow 7-zip execute and press any key to continue if you want to copy to c:\Program Files\7-Zip or close by click x at the top right hand screen
    echo  you can also install the software on your PC from the folder label 7-zip Software installation   
pause
  mkdir "c:\Program Files\7-Zip"
  COPY /Y "7-Zip\*.*" "c:\Program Files\7-Zip"
)

set /P targetfile= Enter target directory to compress : 
set /P targetfilter= Enter filter type : 


:: This one is 7z for file extension  for /f "tokens=*" %%f in ('dir /b *.rdf') do ( "c:\Program Files\7-Zip\7z.exe" a "%%f.7z" "%%f")

:: The below is what we need "%%f.zip"

::  good for the same folder rem for /f "tokens=*" %%f in ('dir /b *.rdf') do ( "c:\Program Files\7-Zip\7z.exe" a "%%f.zip" "%%f")

:: You can change the *.* to any file type you want to compress..... :: I have excluded deleting files after you compressed to avoid missing your file.

for /R "%targetfile%" %%f in ("%targetfilter%") do (

"c:\Program Files\7-Zip\7z.exe" a "%%f.zip" "%%f"

)

if errorlevel 255 goto error
if errorlevel 255 goto error
if errorlevel 8 goto error

if errorlevel 7 echo  command_line_error 
if errorlevel 7 goto error
if errorlevel 2 echo  fatal_error
if errorlevel 2 goto error
if errorlevel 1 echo  OK is warning
if errorlevel 0 echo   very OK successful without warning or error 

 

echo Success!
echo This is a great success to unzip files.

goto end


:error
echo Error! There is error to unzip file in the folder. So it will be terminated. 

timeout 13



:end

pause

