Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

TommyFish29

macrumors newbie
Original poster
Aug 23, 2014
3
0
Hi, so I've been getting into applescript, and Folder Actions, and I wrote this script... Which copies all new screenshots to a variety of locations when they are added to the folder. However, when I use that script as the foundation for my next idea (if the file is a DMG file, copy to a different variety of locations), it fails.

Original Script used as foundation
http://pastie.org/private/t9vkbp5y8rvrvwqts4mciw


Last draft of failed DMG script.
http://pastie.org/private/cyuwkabayodivm9ytybw


- Also attached both scripts as images.

Does anybody have an idea about what I'm doing wrong? I'm stumped.

And yes, I name my folders/servers/external HDs after Legend of Korra / The Last Airbender characters.. I'm a geek like that.


Code:
on adding folder items to thisFolder after receiving added_items
	set OpalLoc to "Opal:Backups:DMGs"
	set MingHuaLoc to "MingHua:Root:Backups:DMGs"
	set GhazanLoc to "Ghazan:Backups:DMGs"
	set ZukoLoc to "Tom:Users:tom:Cloud:Zuko:DMGs"
	
	repeat with addedFile in added_items
		
		tell application "Finder"
			if exists folder OpalLoc and (the name of the addedFile ends with "dmg") then
				
				copy file addedFile to folder OpalLoc
				
			end if
		end tell
		delay 1
		
		tell application "Finder"
			if exists folder MingHuaLoc and (the name of the addedFile ends with "dmg") then
				
				copy file addedFile to folder MingHuaLoc
				
			end if
		end tell
		delay 1
		
		
		
		tell application "Finder"
			if exists folder GhazanLoc and (the name of the addedFile ends with "dmg") then
				
				copy file addedFile to folder GhazanLoc
				
			end if
		end tell
		delay 1
		
		
		
		tell application "Finder"
			if exists folder ZukoLoc and (the name of the addedFile ends with "dmg") then
				
				copy file addedFile to folder ZukoLoc
				
			end if
		end tell
		
		
	end repeat
end adding folder items to

Thanks for the help.
 

Attachments

  • Screen Shot 2014-08-23 at 9.18.24 PM.png
    Screen Shot 2014-08-23 at 9.18.24 PM.png
    90.8 KB · Views: 91
  • Screen Shot 2014-08-23 at 9.18.15 PM.png
    Screen Shot 2014-08-23 at 9.18.15 PM.png
    124.6 KB · Views: 71

kryten2

macrumors 65816
Mar 17, 2012
1,114
99
Belgium
Finder has no knowledge of a copy command. If you want to copy items you need to use the duplicate command.
 

Attachments

  • Screen Shot 2014-08-24 at 05.22.38.png
    Screen Shot 2014-08-24 at 05.22.38.png
    150.1 KB · Views: 53
  • Screen Shot 2014-08-24 at 05.23.08.png
    Screen Shot 2014-08-24 at 05.23.08.png
    166.2 KB · Views: 47
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.