2

Say I have a directory structured as follows:

  • Directory
    • Subdirectory 1
      • file.png
      • file.jpg
    • Subdirectory 2
      • file.png
      • file.jpg

I'd like to burn this to an ISO, but only the .jpg's. I want to preserve the directory structure, though, so that the ISO would look like this:

  • Directory
    • Subdirectory 1
      • file.jpg
    • Subdirectory 2
      • file.jpg

Without copying the whole top-level directory and deleting the things I don't want. I've been reading about "genisoimage" (http://www.tuxarena.com/static/tut_iso_cli.php), but I don't see any built-in mechanism for filtering based on filetype or file name. Is there a way to achieve this with either this tool or another tool, or perhaps combining a tool like grep and piping the output in to genisoimage?

2

You can use mkisofs.

Execute this command in Directory if you want to keep empty directories:

mkisofs -o out.iso -find -name '*.jpg' -o -type d

Execute this command in Directory if you don't want to keep empty directories:

mkisofs -o out.iso -find -name '*.jpg'
1
  • Thank you very much! The removal of empty directories is very useful.
    – Jake
    May 30 '16 at 18:34
1

If you look at man genisoimage you'll find the -m option which takes a "glob" pattern of filenames to exclude, so in your case add the arguments -m '*.png'.

3
  • genisoimage is an unmaintained fork from a mkisofs version from 2004. You don't like to use it as it creates filesystems with defects that may not be accepted by all filesystem implementations in operating systems. The original software fixed aprox. 50 bugs in 2005 and 2006 that are still present in the fork.
    – schily
    May 30 '16 at 18:43
  • Thanks @schily. To find genisoimage, I Googled "Linux make ISO command line", and got this answer: unix.stackexchange.com/questions/90793/…. The top-rated answer with 16 votes is about genisoimage, but the answer with 0 votes is about mkisofs
    – Jake
    May 31 '16 at 13:00
  • This is sad news, but well known. There are people who like to attack OpenSource and these people try to advertize for genisoimage even though they never would use a 12 year old Linux kernel today.
    – schily
    May 31 '16 at 13:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.