mitsuhiko / unp

Unpacks things.
Other
424 stars 56 forks source link

Add --force-basename option #13

Open slafs opened 7 years ago

slafs commented 7 years ago

When extracting multiple similar archives with only one top-level element, user usually wants to have them in a destination directory named after archive's name.

Currently the first archive is extracted to a directory named after the single top-level element while other archives are extracted to directories named after archive's basename.

The --force-basename option is forcing the latter behaviour for every archive.

For example, let's say we have two archives, with only one top-level directory in them (called var):

$ ls BundleLogs*zip
BundleLogs-1495008842230.zip  BundleLogs-1495008843374.zip

When trying to unpack them at once:

$ unp --output /tmp/logs BundleLogs*zip

The default behaviour leaves us with:

$ ls /tmp/logs
BundleLogs-1495008843374  var

Using --force-basename option:

$ unp --force-basename --output /tmp/logs_basename BundleLogs*zip

We get the following result:

$ ls /tmp/logs_basename
BundleLogs-1495008842230  BundleLogs-1495008843374