6

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
codingenious
  • 8,385
  • 12
  • 60
  • 90
moses19850
  • 73
  • 1
  • 6

2 Answers2

6

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
Gordon Davisson
  • 118,432
  • 16
  • 123
  • 151
2

Launch disk utility and select new>blank disk image from folder... It's as simple as that!

mas0701
  • 303
  • 2
  • 12
  • Yes, simple. Unless it tries for a while to make that image, then fails with `Operation failed: Operation not permitted`. This is what I'm getting on creating an image from a user home dir. – roens Aug 20 '18 at 18:33