Hi,
I want to create a batch script which can extract all the jar files existing in a given folder and extracted files are placed in the given folder. Both the paths (source jar files folder and extracted files folder) will be asked by the script when we run the script.
I tried to first take the path from user and extracting files in the same folder but it did't work....
---------------------Batch Script--------------------------------------
@echo off
set /p pathsource= Enter the path where jar files are kept :
echo Source path is %pathsource%.
cd %pathsource%
for /r %pathsource% %i in (*.jar) do jar -xvf %~nxi
echo stop here.
pause
-----------------------------------------------------------------------
Can anyone please help me ?
Thanks
Sanjay
extracting jar files
Moderator: DosItHelp
Re: extracting jar files
Try this:
Code: Select all
@echo off
set /p "pathsource= Enter the path where jar files are kept: "
echo Source path is "%pathsource%"
cd /d "%pathsource%" && (
for %%a in (*.jar) do jar -xvf "%%a"
)
echo stop here (or incorrect path)
pause
Re: extracting jar files
Thanks fox and bill
both Scripts are working fine .........
Can we also provide the destination folder where extracted files will be placed(not in source jar files folder)?

Can we also provide the destination folder where extracted files will be placed(not in source jar files folder)?
Re: extracting jar files
Even if we provide destination path in the script, how to write the final script.
Re: extracting jar files
This might work (untested:)
Code: Select all
@echo off
:loop
set /p "pathsource= Enter the path where jar files are kept: "
set /p "pathtarget= Enter the path to extract jar files to: "
echo Source path is "%pathsource%"
echo Target path is "%pathtarget%"
if not exist "%pathsource%\" goto :loop
if not exist "%pathtarget%\" goto :loop
cd /d "%pathtarget%"
for %%a in ("%pathsource%\*.jar") do jar -xvf "%%a"
echo stop here
pause
Re: extracting jar files
It's working fine..... Thanks a lot fox 
