[SOLVED] Merging Zip Files?

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
karmafarmer

[SOLVED] Merging Zip Files?

Post by karmafarmer »

I'm trying to organise my BBC Micro disk images. The current folder setup goes like this (parenthesis is inside zip file):-

~/bbcg/Acornsoft/Hopper.zip (Acornsoft/Hopper.ssd)
~/bbcg/Acornsoft/Snapper.zip (Acornsoft/Snapper.ssd)
~/bbcg/Superior/Citadel.zip (Superior/Citadel.ssd)
~/bbcg/Superior/Repton.zip (Superior/Repton.ssd)

There's loads more folders and zip files, that's why a little command or script would be helpful. Is there a way to run a command or a script that would take the entire folder bbcg and output either a zip file or folder with the following heirarchy?

~/bbcg/Acornsoft/Hopper.ssd
~/bbcg/Acornsoft/Snapper.ssd
~/bbcg/Superior/Citadel.ssd
~/bbcg/Superior/Repton.ssd

or into a Zip file with a similar format:-

~/bbcg.zip (Acornsoft/Hopper.ssd)
~/bbcg.zip (Acornsoft/Snapper.ssd)
~/bbcg.zip (Superior/Citadel.ssd)
~/bbcg.zip (Superior/Repton.ssd)

So each software house has it's own folder, full of SSD "disk" files from that house...

Thanks

Karl
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
DrHu

Re: Merging Zip Files?

Post by DrHu »

karmafarmer wrote:Is there a way to run a command or a script that would take the entire folder bbcg and output either a zip file or folder with the following hierarchy?
I am not sure what that file type is (not an ssd disk ? is it..)
  • EDIT: Ok, I think I've found it ssd (single sided image files, diskette sizes !)
http://bbc.nvg.org/files.php3
http://www.simplehelp.net/2008/12/15/ho ... -in-linux/
  • --archive file creation/extraction utilities..
    • The desktop (Linux) for Gnome or Kde, also has a zip filer (fileroller : Gnome), for example..
      Kde will have something similar
      --and other desktop styles as well
      • To get a hierarchical archive dump on a Linux system, the default application is tar
So, it looks like you want a larger file archive (appending all the separate files (.ssd)
This utility may work..
http://www.hjsplit.org/linux/

Also the UNIX/Linux utility cat (catenate) or copy /b (binary file) likely will be ok as well
http://www.devdaily.com/unix/edu/examples/cat.shtml
cat x1.zip, x2.zip all.zip (result file)
copy x1.zip x2.zuip xxall.zip (result file)
--or copy /b *.zip all.zip
Last edited by DrHu on Thu Jul 12, 2012 4:16 pm, edited 2 times in total.
User avatar
xenopeek
Level 25
Level 25
Posts: 29459
Joined: Wed Jul 06, 2011 3:58 am

Re: Merging Zip Files?

Post by xenopeek »

I'd do this by creating a new empty directory next to bbcg, called bbcgnew (so they are both subdirectories of the same directory). Then open a terminal and go to the bbcgnew directory. Then run this command:

Code: Select all

for file in $(find ../bbcg -name *.zip); do unzip $file; done
It will find all the zip files in the bbcg directory and unzip them in the bbcgnew directory. After I run the above with your example files in ~/bbcg, it has the files in one directory per software house as you wanted:

Code: Select all

vincent@katya ~/bbcgnew $ tree
.
├── Acornsoft
│   ├── Hopper.ssd
│   └── Snapper.ssd
└── Superior
    ├── Citadel.ssd
    └── Repton.ssd

2 directories, 4 files
You can then zip this however you want.

PS. Fond memories of my old BBC Acorn Electron :wink:
Image
karmafarmer

Re: Merging Zip Files?

Post by karmafarmer »

Thanks, Vincent!

Absolutely beautiful. Did exactly what I wanted. Hundreds of BBC Games, all sorted into folders in a second!

I love those old games, and what's crazy, my kids do too!

Thanks so much :) Now I'm off to retrogame...
Locked

Return to “Scripts & Bash”