Applescript Help...Just the File Name

Discussion in 'Mac Programming' started by Appleismylove, May 12, 2008.

  1. Appleismylove macrumors newbie

    Joined:
    Apr 2, 2008
    Location:
    africa...not
    #1
    Okay, so i'm working on an applescript that gets the file name of a user chosen file (actually i'm making an entire application around it), and i need help. 2 questions
    1. I have gotten the file name and converted it to a POSIX path using this...

    Code:
    	set first_file to choose file without invisibles
    	set thepath to first_file as text
    	set theposix to POSIX path of thepath
    
    :confused:
    How do i get JUST the file name and extension. For example if i get this file /zzz/xxx/ccc/abc.txt
    All i want is the file name (abc.txt) set to a variable like theextension

    2. How do i set the rest of the file path to another variable (/zzz/xxx/ccc/) ? I have been having A TON of trouble with this, and all help is appreciated:D
     
  2. lancestraz macrumors 6502a

    lancestraz

    Joined:
    Nov 27, 2005
    Location:
    RI
    #2
    Put
    Code:
    tell application "Finder" to set file_name to (name of first_file)
    After the first-line and before the second.
     

Share This Page