Entpacken mit "unzip" - jedes in eigenes Verzeichnis

simplex

simplex

[Versuchstier]
Morgen,

habe ein Problem, welches ich mir bislang (und schon lange) nicht selber beantworten kann.

Ich habe viele *.zip Dateien, die nach folgendem Muster aufgebaut sind:

Code:
Bilder Urlaub 1.zip
Bilder Urlaub 2.zip
...
...
Bilder Urlaub n.zip

Nun möchte ich die ganzen Archive in Unterordner entpacken.

Sprich:

Code:
Bilder Urlaub 1.zip soll in /~/Bilder Urlaub 1/ entpackt werden.
Bilder Urlaub 2.zip soll in /~/Bilder Urlaub 2/ entpackt werden.
...
...

Leider weiß ich absolut nicht, wie ich das anstellen soll. Unter KDE geht es nicht wirklich, da er mir dort irgendwann abstürzt und somit muss es auf der Konsole erledigt werden. Mit
Code:
>unzip \*
werden zwar alle Archive fehlerfrei entpackt, aber jedoch in keine Unterordner sondern im aktuellen Verzeichnis.

Für eine Hilfe wäre ich sehr dankbar!

Merci
Micha
 
Ach, wie gut, dass es n Manual gibt:

[-d exdir]
An optional directory to which to extract files. By default, all files and subdirectories are recreated in the current directory; the -d option allows extraction in
an arbitrary directory (always assuming one has permission to write to the directory). This option need not appear at the end of the command line; it is also accepted
before the zipfile specification (with the normal options), immediately after the zipfile specification, or between the file(s) and the -x option. The option and
directory may be concatenated without any white space between them, but note that this may cause normal shell behavior to be suppressed. In particular, ‘‘-d ~’’
(tilde) is expanded by Unix C shells into the name of the user’s home directory, but ‘‘-d~’’ is treated as a literal subdirectory ‘‘~’’ of the current directory.
 
genau dies habe ich mir ja auch schon durchgelesen.

der befehl:

Code:
>unzip -d \*

"By default, all files and subdirectories are recreated in the current directory"

funktioniert aber leider nicht. Da habe ich wohl einen denkfehler drin.
 
Hi,

pardon, ich habe dein Problem vorhin missverstanden, ich dachte du möchtest alle Urlaubsfotos in 1 Ordner entpacken.

Alles in 1:
Code:
unzip -d ~/Urlaubsfotos -x Bilder\ Urlaub\*zip

Wie man für jeden einzelnen einen Ordner anlegt weiß ich ad-hoc leider nicht. - Wenn's nicht zuviele Fotos sind, könnte mans ja übrigens auch manuell machen.
 
das ist ja genau das problem. bei über 200 archiven hat man nicht lust jedes einzeln manuell zu entpacken. dachte es geht irgendwie automatisch, dass er einfach ordnernamen anlegt, die dem archiv übereinstimmen. :) vllt. weiß ja jemand anderes bescheid :)
 
Code:
#!/bin/bash
i=1
while [ $i -le $1 ]
do
  mkdir "Urlaubs Fotos $i"
  unzip -x "Bilder Urlaub $i.zip"
  i=`expr $i + 1`
done

Selbst ist der Mann.

Aufruf: *.sh ANZAHLDERORDNER
 
oder als einfacher einzeiler :

Code:
for i in *.zip; do x=`echo $i | cut -f1 -d.` ; unzip -d $x $i; done
 
Code:
#!/bin/bash
i=1
while [ $i -le $1 ]
do
  mkdir "Urlaubs Fotos $i"
  unzip -x "Bilder Urlaub $i.zip"
  i=`expr $i + 1`
done

Selbst ist der Mann.

Aufruf: *.sh ANZAHLDERORDNER


vielen dank für die antworten! :)

dein post enthiel noch einen fehler! korrekt wäre:

Code:
unzip -d "Bilder Urlaub $i" -x "Bilder Urlaub $i.zip"

ansonsten legt er zwar die ordner an..aber extrahiert trotzdem im verzeichnis an sich und nicht in den ordnern :) danke danke danke
 
Zurück
Oben