cyclemat
Goto Top

Massenweise RAR Dateien zu ZIP Dateien Convertieren

Hi habe so ein kleines problem habe hier eine sammslung an rar dateien die ins zip format gebracht werden müssen.

Hi habe so ein kleines problem habe hier eine sammslung an rar dateien die ins zip format gebracht werden müssen,
damit ich sie in einem datenbank programm weiter verarbeiten kann dieses kann aber nur zip dateien lesen.

die Ordner Struktur sieht so aus

C:\ordner\user1\*.rar
C:\ordner\user2\*.rar
c:\ordner\system\standort\*.rar

habe auch schon ein script gefunden das *.rar dateien umändert in zip doch nur wenn sie in einem Verzeiniss liegen.

wie bekomme ich also das script so hin das es das macht was ich möchte nämlich das er alle bei angegebenem ordner C:\ordner
alle unterordner nach *.rar dateien durchsucht, und alle *.rar dateien zu zip dateien macht und diese dann wieder im selben ordner wie die quell rar liegt !?!


ach ja ist nen windows rechner falls einer fragen will


Hier das Script
@echo off
echo Zip Converter (c) 2009-2011 W-Shadow, http://w-shadow.com/
setlocal

rem ==============================================
rem 			Find the 7z executable
rem ==============================================

rem Check the most likely 7-Zip installation path
if exist "C:\Program Files\7-Zip\7z.exe" (set archiver="C:\Program Files\7-Zip\7z.exe") else (goto :detect64bit)  
goto :startprocessing

:detect64bit
if exist "C:\Program Files (x86)\7-Zip\7z.exe" (set archiver="C:\Program Files (x86)\7-Zip\7z.exe") else (goto :detect7z)  
goto :startprocessing

:detect7z
rem See if 7z is directly accessible
7z.exe > nul
if %errorlevel% == 0 (set archiver="7z.exe") else (goto :no7zip)  

:startprocessing
rem Is the input pattern set?
if "%1"=="" goto :nopattern  

rem Is the output folder set? (optional - by default, the current directory is used)
if not "%2"=="" (set outdir="%~dp2") else (set outdir=".\")  

rem ==============================================
rem 			Convert files
rem ==============================================
rem Loop over all files matching the input pattern
for %%f in (%1) do (
	echo.
	echo ======================================================
	echo Converting file %%~nxf...
	echo ======================================================

	rem Extract the archive to a temporary folder
	%archiver% x "%%f" -y -o"%temp%\%%~nf.tmp"  

	rem Compress the folder's contents to zip  
	%archiver% a "%outdir%%%~nf.zip" -mx7 "%temp%\%%~nf.tmp\*"  

	rem Remove the temporary folder
	rd /s /q "%temp%\%%~nf.tmp"  
)

goto :end

:nopattern
echo Convert most archives to the ZIP format using 7-Zip ( http://www.7-zip.org/ )
echo.
echo Syntax : %~n0 {input_pattern} [output_directory]
echo Examples : 
echo      %~n0 file.cab
echo      %~n0 *.rar
echo      %~n0 *.iso "d:\temp\"  
goto :end

:no7zip
echo Error : 7-Zip not found!
echo Please install 7-Zip (www.7-zip.org) and add it's directory to the PATH environment variable.  

:end
endlocal


Danke schonmal im vorraus.

[Edit Biber] Codeformatierung [/Edit]

Content-Key: 184331

Url: https://administrator.de/contentid/184331

Printed on: April 16, 2024 at 05:04 o'clock

Member: NetWolf
NetWolf May 02, 2012 at 09:37:01 (UTC)
Goto Top
Moin Moin,

hier findest du ein vollständiges Tutorial mit Code für dein Problem.
(man muss das Rad ja nicht immer wieder neu erfinden)

Grüße aus Rostock
Wolfgang
(Netwolf)
Member: pieh-ejdsch
pieh-ejdsch May 02, 2012 at 10:05:13 (UTC)
Goto Top
moin cyclemat,

wie bekomme ich also das script so hin das es das macht was ich möchte nämlich das er alle bei angegebenem ordner C:\ordner alle unterordner nach *.rar dateien durchsucht, und alle *.rar dateien zu zip dateien macht und diese dann wieder im selben ordner wie die quell rar liegt !?!

Dann übergib im CMD-Fenster doch die Pfade in einer /Rekursiven For Schleife an den Batch:

for /R "C:\ordner" %i in (*.rar) do "C:\Zipconverter.cmd" "%i"  

PS: das ist dann auch kein neues Rad.

Gruß Phil
Member: cyclemat
cyclemat May 03, 2012 at 06:21:40 (UTC)
Goto Top
Also in beiden fällen komme ich zu dem Ergebniss das er mir immer sagt kann angegebenen Pfad nicht finden.
könnte damit zusammen Hängen das Leerzeichen in im Dateinamen sind ?!!?


egal wie ich die "" setze bekomme es nicht hin !
Member: cyclemat
cyclemat May 03, 2012 at 06:58:01 (UTC)
Goto Top
also muss das rad doch neu erfunden werden ?!?!
Member: Biber
Biber May 03, 2012 at 08:19:40 (UTC)
Goto Top
Moin cyclemat,

musst ja nicht ein komplettes Rad erfinden, bau einfach noch eine Tilde ein...

for /R "C:\ordner" %i in (*.rar) do "C:\Zipconverter.cmd" "%~i"  

Grüße
Biber
Member: cyclemat
cyclemat May 04, 2012 at 11:26:33 (UTC)
Goto Top
Habe es jetzt so hinbekommen funtzt alles sehr schön blos packt es mir die dateien in den ordner wo die batch liegt möchte aber das die zip da geschrieben wird wo sich auch die quell rar datei befindet da es vorkommen kann das 2 dateien den gleichen namen unter 2 verschiedenen pfaden haben
@echo off
echo Zip Converter (c) 2009-2011 W-Shadow, http://w-shadow.com/
setlocal

rem ==============================================
rem 			Find the 7z executable
rem ==============================================

rem Check the most likely 7-Zip installation path
if exist "C:\Program Files\7-Zip\7z.exe" (set archiver="C:\Program Files\7-Zip\7z.exe") else (goto :detect64bit)  
goto :startprocessing

:detect64bit
if exist "C:\Program Files (x86)\7-Zip\7z.exe" (set archiver="C:\Program Files (x86)\7-Zip\7z.exe") else (goto :detect7z)  
goto :startprocessing

:detect7z
rem See if 7z is directly accessible
7z.exe > nul
if %errorlevel% == 0 (set archiver="7z.exe") else (goto :no7zip)  

:startprocessing
rem Is the input pattern set?
if "%1"=="" goto :nopattern  

rem Is the output folder set? (optional - by default, the current directory is used)
if not "%2"=="" (set outdir="%~dp2") else (set outdir=".\")  

rem ==============================================
rem 			Convert files
rem ==============================================
rem Loop over all files matching the input pattern

for /r %%f in (%1) do (

	echo.
	echo ======================================================
	echo Converting file %%~nxf...
	echo ======================================================

	rem Extract the archive to a temporary folder
	%archiver% x "%%f" -y -o"%temp%\%%~nf.tmp"  

	rem Compress the folder's contents to zip  
	%archiver% a "%outdir%%%~nf.zip" -mx7 "%temp%\%%~nf.tmp\*"  

	rem Remove the temporary folder
	rd /s /q "%temp%\%%~nf.tmp"  
)

goto :end

:nopattern
echo Convert most archives to the ZIP format using 7-Zip ( http://www.7-zip.org/ )
echo.
echo Syntax : %~n0 {input_pattern} [output_directory]
echo Examples : 
echo      %~n0 file.cab
echo      %~n0 *.rar
echo      %~n0 *.iso "d:\temp\"  
goto :end

:no7zip
echo Error : 7-Zip not found!
echo Please install 7-Zip (www.7-zip.org) and add it's directory to the PATH environment variable.  

:end
endlocal

[Edit Biber] Codeformatierung [/Edit]
Member: bastla
bastla May 06, 2012 at 12:14:01 (UTC)
Goto Top
Hallo cyclemat!

Versuch es mal mit folgender Zeile 42:
%archiver% a "%%~dpnf.zip" -mx7 "%temp%\%%~nf.tmp\*"
Grüße
bastla