[AS]Do Shell Script: File Segmenting

Is anyone familiar with the shell script for file segmenting? I’m working on an applescript that creates an image of a folder and then segments that dmg file so it can be burned to disc. My issue is I can’t figure out how to set the destination folder for the segment-dmgs that are created (preferably the same folder where the original dmg is located).

Here’s what I have:


set thefinalimagefile to POSIX path of thefinalimagefile--puts final file path of newly made dmg into correct format
do shell script ("hdiutil segment -o mydvd -segmentSize 650M " & thefile) user name "NAME" password "PASS" with administrator privileges--this works, but files are saved to Mac HD

I know there’s a way to add a destination folder to the shell script but nothing is working so far. So my system defaults to placing the new dmgs onto Mac HD which is very annoying.

Any help is greatly appreciated.

Stacy

Hi,

something like this?


set destinationFolder to choose folder
set thefinalimagefile to POSIX path of thefinalimagefile --puts final file path of newly made dmg into correct format
do shell script ("hdiutil segment -o " & quoted form of (POSIX path of destinationFolder & "mydvd") & " -segmentSize 650M " & thefile) user name "NAME" password "PASS" with administrator privileges --this works, but files are saved to Mac HD

Thank you, that did it!!!

Hi

I have been trying to adapt this script to allow me to select a DMG, then segment it in chosen folder at chosen segment size.

I have this:

set thefinalimagefile to choose file of type {"dmg"} with prompt "SELECT DMG DISK IMAGE TO SEGMENT"
set {TID, text item delimiters} to {text item delimiters, ":"}
set filename to last text item of (thefinalimagefile as text)
set text item delimiters to TID
set filename to "SEGMENT_" & filename
set thefile to POSIX path of the thefinalimagefile
set segmentsize to display dialog "SELECT SEGMENT SIZE (IN MB)" default answer 2000
set segmentsize to text returned of segmentsize
set destinationFolder to choose folder with prompt "SELECT DESTINATION FOLDER"
do shell script ("hdiutil segment -o " & quoted form of (POSIX path of destinationFolder & filename) & " -segmentSize " & segmentsize & "M " & thefile) user name "XXX" password "XXX" with administrator privileges

Unfortunately, the shell script throws an error saying:

Can anyone point me in the right direction?

Thanks

Answered my own problem. Needed the quoted form for input file:

set thefinalimagefile to choose file of type {"dmg"} with prompt "SELECT DMG DISK IMAGE TO SEGMENT"
set {TID, text item delimiters} to {text item delimiters, ":"}
set filename to last text item of (thefinalimagefile as text)
set text item delimiters to TID
set filename to "SEGMENT_" & filename
set thefile to POSIX path of the thefinalimagefile
set segmentsize to display dialog "SELECT SEGMENT SIZE (IN MB)" default answer 900
set segmentsize to text returned of segmentsize
set destinationFolder to choose folder with prompt "SELECT DESTINATION FOLDER"
do shell script ("hdiutil segment -o " & quoted form of (POSIX path of destinationFolder & filename) & " -segmentSize " & segmentsize & "M " & quoted form of thefile) user name "XXX" password "XXX" with administrator privileges

Works for me. Segments a 31GB DMG into 33 parts in under 4 minutes on my MacBook Pro SSD . Double clicking on the first segment opens the DMG just as if it was a single DMG, but with the advantage now that I can automatically backup the data to the cloud with ZipCloud (which has file size limit of 1Gb or 5Gb depending on your plan).