Welcome, Guest. Please login or register.

Author Topic: Recursively unpack a collection of files, maintaining directory structure?  (Read 774 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline CalabTopic starter

  • Newbie
  • *
  • Join Date: Nov 2020
  • Posts: 19
  • Gender: Male
    • Show only replies by Calab
I have a collection of files, in a directory tree. They are in many ZIP and LHA formatted files.  I wish to unpack all the files, while maintaining the directory structure, to a different location.

Can someone suggest a simple script I can run that will do this?

The current tree looks like:
Code: [Select]
Maindir
   file1.zip
   dir1
      dir2
         file2.lha
         file3.zip
      dir3
         file4.lha
   dir4
      file5.zip

and should look like this after the script is run:

Code: [Select]
Altdir
   file1
   file1.icon
   dir1
      dir2
         file2
         file2.icon
         file2.readme
         file3
      dir3
         file4
         file4.info
         file4.dir
            file4.readme
   dir4
      file5
 

Offline lionstorm

lha has recursive dir as option

lha ?
LhA Freeware Version 2.15 AOS4
Copyright (c) 1991-94 by Stefan Boberg.
Copyright (c) 1998,1999 by Jim Cooper and David Tritscher.
Copyright (c) 2004-2011 by Sven Ottemann.

Usage: LhA [-<options>] <command> <archive[.LZH/LHA]> [[homedir]
           <filespec>...] [@file] [destdir]

                        Where <Command> is one of:

  a    Add files                       c    Concatenate/Append archives
  d    Delete files                    e    Extract files
  f    Freshen files                   h    Hunt for diffs arc <-> filesys
  l[q] List archive (terse)            m    Move files to archive
  p    Print files to stdout           r    Replace files
  t    Test archive integrity          u    Update archive
  v[q] List archive (verbose)          vv   Show archive contents (full)
  x    Extract files with full path    y    Copy archive with new options

                      And <Options> is one or more of:

 -a  Preserve file attributes (D)     -A  Set archive attributes (D)
 -b  Set I/O buffer size (KB)         -B  Keep backup of archive
 -c  Confirm files                    -C  Clear arc-bit on extract (D)
 -d  Archive date = newest file       -D  Alternate progress display
 -e  Archive empty directories        -E  Touch extracted files
 -f  Ignore filenotes                 -F  Use fast progress display
 -G  Only extract newer files         -h  Disable homedirectories
 -H  Write header level ( 0,1,2 )     -i  Read filelist from file
 -I  Ignore ENV:LHAOPTS               -k  Keep partial files
 -K  Kill empty directories (move)    -l  Make filenames lowercase
 -L  Create filelist                  -m  No messages for query
 -M  No autoshow files                -n  No byte progress indicator
 -N  No progress indicator            -o  On or after date (newer than)
 -O  On or before date (older than)   -p  Pause after loading
 -P  Set task priority                -q  Be quiet
 -Q  Alternate option set introducer  -r  Collect files recursively
 -R  Collect archives recursively     -s  Only add files with A flag unset
 -S  Set A flag on added files (D)    -t  Only extract new files
 -T  Only extract new & newer files   -u  Make filenames uppercase
 -V  Enable/set multivolume size(KB)  -w  Set work directory
 -W  Exclude filenames                -x  Preserve and use path names
 -X  Do not append LZH/LHA suffix     -y  Always append LZH/LHA suffix
 -Y  Store big files w.ratio < 3%     -z  Do not compress files
 -Z  Compress archives                -0  Use LhArc V1.x compression
 -2  Use LHA V2.x compression (-lh5-) -3  Use LHA V2.x compression (-lh6-)

                             Alternate options:

 -Qa Use simple console I/O           -Qb Test archive before extract
 -Qd Delete autoshow files            -Qh Set Huffman buffer size (KB)
 -Qm Use filename 'munging'           -Qn Set national character mode
 -Qo Ignore options after cmd         -Qp Ignore delete protection flag
 -Qq Quick add                        -Qr Skip datestamp check
 -Qv Set multivolume arc devices      -Qw Disable wildcards

  Options are case-sensitive and may be specified anywhere on the command
line, the option letter followed by a 0 disables the option, any non-zero
digit will enable it. If no digit follows the option letter, it will be
enabled. Some options are enabled by default (depending on used command),
the default compression is LHA V2.x-style (-lh5-) compression. For more
info please consult the user's manual.

  The destination directory must have a trailing slash (/) or colon (:).
 

Offline TribbleSmasher

one would need to make a script that uses e.g. LIST LFORMAT to create another script with lines like

LHA X    path/.../

and

UNZIP path/.../

depending on the type or extension.
 

Offline CalabTopic starter

  • Newbie
  • *
  • Join Date: Nov 2020
  • Posts: 19
  • Gender: Male
    • Show only replies by Calab
Re: Recursively unpack a collection of files, maintaining directory structure?
« Reply #3 on: February 17, 2024, 05:11:03 PM »
Sorry for the late reply... I'm not getting notifications for my posts.

Thanks for the suggestions. I scrapped the idea of unpacking all the files and will just unpack what I need when I need it.
 

Offline Boing-ball

Re: Recursively unpack a collection of files, maintaining directory structure?
« Reply #4 on: February 18, 2024, 01:54:07 AM »
You could just simply use Dopus to do that in a GUI way 😉