set sourceFolder to POSIX path of (choose folder with prompt "choose source folder")
set sourceFolderName to name of (info for sourceFolder)
set destinationFolder to POSIX path of (choose folder with prompt "choose destination folder")
set sourceFolder2 to POSIX path of sourceFolder
set dmgFileNamePath to (sourceFolderName & ".dmg")
set myNewPath to destinationFolder & dmgFileNamePath
try
do shell script "hdiutil create -encryption AES-128 -size 500m -format UDRW -nospotlight -srcfolder " & sourceFolder2 & " -volname " & quoted form of sourceFolderName & " " & myNewPath
end try
Hi. I don’t see a “nospotlight” option in the hdiutil man page.
This works for me:
set isTarget to (choose folder) as text
do shell script "hdiutil create -encryption -format UDRW -srcfolder" & space & ((isTarget)'s POSIX path's quoted form) & space & (isTarget's text 1 thru -2 & ".dmg")'s POSIX path's quoted form
An ioctl, or input/output control, has something to do with the kernel; the error that its “incompatible with the peripheral” is not particularly helpful, and, unfortunately, is too arcane for me. Perhaps it will help others to help you, if you post your OS version. I tested my code in OS 10.9.5.
I don’t know if the OP is still looking for an answer at this point, however, after installing Sierra and revisiting this question, the error appears related to a permissions issue.
set sourceFolder to (choose folder with prompt "select a folder to store") as text
set destination to (choose folder with prompt "define an end point") as text
set fileVar to "nom" --the dmg's filename
#iConcerning volname, not specifying same results in volname = sourceFolder
do shell script "printf 'whatever password' | hdiutil create -srcfolder " & sourceFolder's POSIX path's quoted form & " -encryption -stdinpass -fs HFS+" & space & (destination & fileVar)'s POSIX path's quoted form
--if volname desired
--set volumeVar to "expanded" --the mounted dmg's name
--do shell script "printf 'whatever password' | hdiutil create -srcfolder " & sourceFolder's POSIX path's quoted form & " -encryption -stdinpass -fs HFS+ -volname " & volumeVar's quoted form & space & (destination & fileVar)'s POSIX path's quoted form