Copy to DMG

How do I copy a file to a .dmg? Here’s what I tried:


set fldr to "Gentfamdisc:Users:Tim:Desktop:.Folder.dmg" as alias
set Lfldr to "Gentfamdisc:Users:Tim:Desktop:PW gate plans:Timothy's load folder" as alias
tell application "Finder"
	open fldr
	set newstuffs to (list folder Lfldr) as list
	set Citem to 2
	set Titems to (the number of items in newstuffs) - 1
	repeat Titems times
- -HELP!****************************************************************
		duplicate alias (Lfldr & newstuffs's item Citem as text) to alias fldr
- -HELP!****************************************************************
		set Citem to Citem + 1
	end repeat
end tell

I’ve tried everything.
Copy, Move, Duplicate to nothing, Alias, Disk, Dmg, Folder, Disk image

All notes greatly accepted.

hi fisto,

when you mount the .dmg file, you should see it under the ‘/Volumes’ (hidden) folder. so when you copy you might try this:


set fldr to "Gentfamdisc:Users:Tim:Desktop:.Folder.dmg" as alias
set Lfldr to "Gentfamdisc:Users:Tim:Desktop:PW gate plans:Timothy's load folder" as alias
tell application "Finder"
	open fldr
        delay 5
	set newFldr to "Gentfamdisc:Volumes:Folder" as alias
	set newstuffs to (list folder Lfldr) as list
	set Citem to 2
	set Titems to (the number of items in newstuffs) - 1
	repeat Titems times
		duplicate alias (Lfldr & newstuffs's item Citem as text) to alias newFldr
		set Citem to Citem + 1
	end repeat
end tell

i haven’t tested this, but i think i’ve got the concept correct. should work…

EDITED: i did test this & needed to add a delay (so the disk mounts before we start copying to it) as well as the full path to the Volumes folder. i still get an error: “Finder got an error: Can’t make some data into the expected type.”, but i feel that may be my data and has nothing to do with writing to a .dmg file.

I get as far as in the other script. I just get an error saying that Applescript “can’t make some data into the expected type” I tied using a folder and an aiff. Nothing doing…

I got your idea to work. I removed the "Alias"es and changed it to “copy” andd now it works fine.

hi fisto,

glad to hear. here is another way to do it:


set fldr to "Gentfamdisc:Users:Tim:Desktop:.Folder.dmg" as alias
set Lfldr to "Gentfamdisc:Users:Tim:Desktop:PW gate plans:Timothy's load folder" as alias
set Pfldr to "/Users/Tim/Desktop/PW gate plans/Timothy's load folder/"
tell application "Finder"
	open fldr
	delay 5
	set newFldr to "/Volumes/Folder"
	set newstuffs to (list folder Lfldr) as list
	set Citem to 2
	set Titems to (the number of items in newstuffs) - 1
	repeat Titems times
		do shell script "/bin/cp " & quoted form of (Pfldr & newstuffs's item Citem) & " " & newFldr
		set Citem to Citem + 1
	end repeat
end tell

i’ve had good results with this–sorry i was away for a bit.

cheers.