Search code examples
macosdirectoryiso

Create ISO image from folder


I wrote a script which creates and ISO image from a folder, but when the folder contains spaces, I get an error message. Can somebody please help me? I'm working with Mac OSX Mavericks and Terminal.

Thanks in advance.

Script:

#!/bin/sh
cd /Volumes/Daten/fake
for i in ./*; do hdiutil makehybrid -udf -joliet -iso -o /Volumes/Daten/test/$i ./*;done

error:

hdiutil: makehybrid: multiple sources specified

Solution

  • Use double-quotes around all variable references (e.g. "$i") to prevent word splitting. BTW, it also looks like your script will fail if there's more than one item in /Volumes/Daten/fake, because the ./* at the end of the hdiutil command will try to include all of the items in each image, which will also fail. Finally, ./* is generally unnecessary; just use *. I think you want this:

    #!/bin/sh
    cd /Volumes/Daten/fake
    for i in *; do
        hdiutil makehybrid -udf -joliet -iso -o "/Volumes/Daten/test/$i" "$i"
    done