Simple Applescript to get folder names, parent folder paths, and folder paths.

Discussion in 'Mac Programming' started by Koby3663, Feb 2, 2011.

  1. Koby3663 macrumors newbie

    Joined:
    Feb 2, 2011
    #1
    Hey I just could not find a simple resource to get these three things out of a folder path. This takes the folder and breaks it down to 3 levels the folder name, folder path, and the parent folder path.

    Code:
    tell application "Finder"
    	
    	set FolderPath to (choose folder) -- sets file path to folder you select
    	set ParentFolder to container of FolderPath -- sets the parent folder of the folder you select
    	set Foldername to name of folder FolderPath -- sets the folder name as text
    	
    	display dialog FolderPath as text
    	display dialog ParentFolder as text
    	display dialog Foldername as text
    	
    	
    end tell
     
  2. MediaGeek macrumors newbie

    Joined:
    Feb 17, 2011
    #2
    Thanks for this

    I know you posted this awhile ago, but thanks for putting it up. It was a simple thing that was hanging me up as well.
     

Share This Page