Applescript, look after file don't work why?

Discussion in 'Mac Programming' started by Dirtyharrydev, Jan 17, 2014.

  1. Dirtyharrydev macrumors member

    Joined:
    Aug 5, 2013
    #1
    Hi,
    I'm trying to get my script to look if a file exist on a SMB server, but I can't get it to work.
    I know that the file are there.

    Can someone help me please?

    Code:
    set connection to "smb://xx:xx@10.0.1.2/Webb"
    set DownloadFolder to (path to downloads folder) as string
    set UpdateFile to "xxx_v1.0b04.zip"
    set UpdateFolder to ("smb://xxx:xxx@10.0.1.2/Webb/" & UpdateFile) as string
    
    
    
    
    tell application "Finder"
    	mount volume connection
    end tell
    
    
    tell application "Finder"
    	if exists file UpdateFolder then
    		set theAction to button returned of (display dialog "There is a new update." buttons {"Download later", "Download now"} default button {"Download now"})
    		if theAction = "Download now" then copy file UpdateFolder to DownloadFolder
    		delay 100
    	end if
    end tell
    
     
  2. kryten2 macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #2

    Try this :

    Code:
    set connection to "smb://xx:xx@10.0.1.2/Webb"
    set DownloadFolder to path to downloads folder
    set UpdateFile to "xxx_v1.0b04.zip"
    
    set mountedVolSpecifier to mount volume connection
    
    tell application "Finder"
    	if exists file UpdateFile of folder mountedVolSpecifier then
    		set theAction to button returned of (display dialog "There is a new update." buttons {"Download later", "Download now"} default button {"Download now"})
    		if theAction = "Download now" then duplicate file UpdateFile of folder mountedVolSpecifier to folder DownloadFolder
    	end if
    end tell
    
     

Share This Page