Applescript help

Discussion in 'Mac Apps and Mac App Store' started by TommyFish29, Aug 23, 2014.

  1. TommyFish29 macrumors newbie

    Joined:
    Aug 23, 2014
    #1
    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.
     

    Attached Files:

  2. kryten2 macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #2
    Finder has no knowledge of a copy command. If you want to copy items you need to use the duplicate command.
     

    Attached Files:

  3. TommyFish29 thread starter macrumors newbie

    Joined:
    Aug 23, 2014
    #3
    I don't think that's it bro because the original uses the copy command and works perfectly.
     

Share This Page