Help Request : Stuck trying to create a folder and refining script

I’m trying to write a script to copy, then uncompress a virtual machine into the proper folder. I was going fine on my test box, then i tried it on another box and realized i never put a check in to see if the folder existed so I made a mighty stab at doing that only to confuse myself even more. I also realized I hadn’t accounted for different user names, but I think I accounted for that now. Is anyone willing to look at my script and tell me where I went wrong and what I could do to improve it?

Len


tell application "Finder"
	set path_1 to "Users:[home]:Documents:Virtual Machines:"
	set path_2 to POSIX path of path_1
	set path_3 to "Volumes:Kingston:Extra Files:"
	set path_4 to POSIX path of path_3
	set path_5 to "Users:[home]:Documents:
	set path_6 to POSIX path of path_5
end tell

tell application "Finder"
	if (not exists with properties {name:"Virtual Machines"}) in folder "Users:[home]:Documents:"
	 then
		make new folder at "users:[home]:Documents:" with properties {name:"Virtual Machines"}
	end if
	
end tell


say "Beginning file copy"
do shell script "/bin/cp " & quoted form of path_4 & "Windows7HomePremium.zip " & quoted form of path_2
say "File copy complete"

say "beginning file decompression"

do shell script "unzip -u " & quoted form of path_2 & "Windows7homepremium.zip" & "  -d " & quoted form of path_2

say "file decompression complete"

do shell script "rm " & quoted form of path_2 & "Windows7homepremium.zip"

Model: Macbook Pro
Browser: Safari 531.9
Operating System: Mac OS X (10.6)

Hi,

try this (sorry, I don’t like meaningless variable names :wink: )


property windowsHomeZIP : "Windows7homepremium.zip"

set virtualMachinesFolder to POSIX path of (path to documents folder) & "Virtual Machines/"
set kingstonExtraFilesFolder to "/Volumes/Kingston/Extra Files/"

do shell script "/bin/mkdir -p " & quoted form of virtualMachinesFolder -- creates folder only if necessary
say "Beginning file copy"
do shell script "/bin/cp " & quoted form of (kingstonExtraFilesFolder & windowsHomeZIP) & space & quoted form of virtualMachinesFolder

say "File copy complete"
say "beginning file decompression"

do shell script "/usr/bin/unzip -u " & quoted form of (virtualMachinesFolder & windowsHomeZIP) & " -d " & quoted form of virtualMachinesFolder
say "file decompression complete"

do shell script "/bin/rm -r " & quoted form of (virtualMachinesFolder & windowsHomeZIP)


Thank you so very much, and much much cleaner. Now all I need to do is figure out how to do a progress bar (which I believe is addressed somewhere else on this site) and I can call this POS done. took you 5 minutes to do what it took me 2 days to figure out.
Thanks again.
Len