Applecript n00b, please help

Discussion in 'Mac Programming' started by GoaTrancer, Feb 20, 2012.

  1. GoaTrancer, Feb 20, 2012
    Last edited: Feb 20, 2012

    macrumors newbie

    Joined:
    Jan 14, 2008
    #1
    I have written the following script. I get no errors when I test it, yet nothing happens when I run it

    Code:
    try
    	
    	
    	
    	tell application "Finder"
    		move file "/Users/alexk/synctest/Untitled3.rtf" to folder "/Users/alexk/Dropbox/nupdftest"
    		
    		
    	end tell
    end try
    I have tried a couple other things in place of duplicate (copy, move), yet no matter what, after running the script I do not find the file in the target folder, "nupdftest"

    Edit: the error I get back is "error number -1728 from file "/Users/alexk/synctest/Untitled3.rtf"
    I'm googling around to find out what that means in this context but not having a lot of luck. That path is absolutely correct, I double and triple checked.

    Any ideas what is going wrong here?
    Apologies in advance for what is probably a dumb question.. but I've googled around and can't figure out what's bad about my script.
    PS in case you are wondering why I've made such a pointless script, it's just part of process of figuring out why a different script wasn't working, I just simplified it to eliminate sources of error.
     
  2. macrumors 6502

    Joined:
    May 29, 2011
    Location:
    Littleton, Colorado, USA
    #2
    The Finder doesn't know about POSIX paths, it uses the colon delimited HFS paths. You can coerce to POSIX files, or use System Events.
     
  3. thread starter macrumors newbie

    Joined:
    Jan 14, 2008
    #3
    Great, that solved it, my script now works as intended. Thanks!
     
  4. macrumors newbie

    Joined:
    Feb 19, 2012
    #4
    How would the script look if I wanted to move all files in a specific folder?
     
  5. macrumors 6502

    Joined:
    May 29, 2011
    Location:
    Littleton, Colorado, USA
    #5
    That would be move entire contents of ...
     
  6. r0k
    macrumors 68040

    r0k

    Joined:
    Mar 3, 2008
    Location:
    Detroit
    #6
    Code:
    try
    	
    	
    	
    	tell application "Finder"
    		move (files of folder ":Users:alexk:synctest:" whose name does not start with ".") to (":Users:alexk: Dropbox:nupdftest")
    		
    		
    	end tell
    end try
    I had to give a partial filename because if you run this without any file name, it starts by trying to move . and .. which of course can't be moved and you get error -17 somethingorother.
     

Share This Page