jverasql
asked on
how would I unzip zip files using a bat file?
I have this batch script, which works but now I want to add to it.
@ECHO OFF
set mydate=%date:~-4%%date:~4, 2%%date:~7 ,2%
copy C:\Users\nabbo\*%mydate%*. zip C:\Users\nabbo\test
Using a .bat script file, how would I unzip zip files in C:\Users\nabbo\test? I found this below, but it does not work.
@echo off
setlocal
rem Define folder to process and location of 7-zip exe file
set BaseDir=C:\Users\nabbo\tes t\
set ZipExe=c:\Program Files\7-zip\7z.exe
rem If base directory not found quit
if not exist "%BaseDir%\" (
echo.*ERROR* - Base directory not found [%BaseDir%].
exit /b
)
rem If zip program not found quit
if not exist "%ZipExe%" (
echo.*ERROR* - Zip program not found [%ZipExe%].
exit /b
)
REM Process all zip files in folder
for %%A in ("%BaseDir%\*.zip") do (
REM Extract desired file to destination folder
if not exist "%BaseDir%\%%~nA" md "%BaseDir%\%%~nA"
"%ZipExe%" e "%%~A" -o"%BaseDir%\%%~nA"
)
The error below results but the path does exist
C:\Users\nabbo>testzip.bat
The system cannot find the path specified.
*ERROR* - Zip program not found ["C:\Program Files\7-Zip\7z.exe"].
@ECHO OFF
set mydate=%date:~-4%%date:~4,
copy C:\Users\nabbo\*%mydate%*.
Using a .bat script file, how would I unzip zip files in C:\Users\nabbo\test? I found this below, but it does not work.
@echo off
setlocal
rem Define folder to process and location of 7-zip exe file
set BaseDir=C:\Users\nabbo\tes
set ZipExe=c:\Program Files\7-zip\7z.exe
rem If base directory not found quit
if not exist "%BaseDir%\" (
echo.*ERROR* - Base directory not found [%BaseDir%].
exit /b
)
rem If zip program not found quit
if not exist "%ZipExe%" (
echo.*ERROR* - Zip program not found [%ZipExe%].
exit /b
)
REM Process all zip files in folder
for %%A in ("%BaseDir%\*.zip") do (
REM Extract desired file to destination folder
if not exist "%BaseDir%\%%~nA" md "%BaseDir%\%%~nA"
"%ZipExe%" e "%%~A" -o"%BaseDir%\%%~nA"
)
The error below results but the path does exist
C:\Users\nabbo>testzip.bat
The system cannot find the path specified.
*ERROR* - Zip program not found ["C:\Program Files\7-Zip\7z.exe"].
Do you have 7zip installed in that path (C:\Program Files\7-Zip\7z.exe) ?
ASKER
yes
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
got it to work
Dr Klahn you brought up a good point. I got this work locally, but it was a test. I just realized I want this work on a network where I do not know where the zip software is installed. How would unzip all zip files in a folder not knowing where the zip software is located?
Dr Klahn you brought up a good point. I got this work locally, but it was a test. I just realized I want this work on a network where I do not know where the zip software is installed. How would unzip all zip files in a folder not knowing where the zip software is located?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you all for the help. I apologize for the delay in response.