Getting the path of the parent folder of a file?

How can I get the parent folder/directory of a file? I cant't find any actions i Automator that will give me this.
Will I have to do this through AppleScript? If so, then how?
Anders

Mine should work as a stand-alone applescript droplet (save it as an application) from Script Editor.
This code will work in an Automator "Run Applescript" Action after a "Get Selected Finder Items" action:on run {input, parameters}
set pathList to {}
repeat with itemNum from 1 to count of input
tell application "System Events"
copy POSIX path of (container of (item itemNum of input)) to end of pathList
end tell
end repeat
return pathList
end run
It returns an Applescript list of each path for all the selected finder items. I had to change (number of items of) to (count of) as it failed in the Automator workflow.
If your workflow will only process one item at a time, then this will work in the workflow:on run {input, parameters}
tell application "System Events"
set thePath to POSIX path of (container of (item 1 of input))
end tell
return thePath
end run

Similar Messages

  • How to get the enclosing folder of an Application?

    Ok. re-visiting my Applescript to compare installed apps versus a list of predefined apps... here is my test code so far:
    set appsPath to (path to applications folder)
    tell application "Finder"
      set appList to name of every application file of entire contents of folder appsPath
    end tell
    set theApps to {"iMovie.app", "Microsoft Excel", "Microsoft Excel.app", "Adobe Acrobat 7.0 Professional.app", "Adobe After Effects CS4.app", "ColorEyes Display Pro.app", "Corel Painter X.app", "DiskTracker 2.3.2", "EPSON Scan.app", "Flash 8.app", "Product Ingest.app", "Product Tag.app", "Art Ingest.app", "TextWrangler.app", "Toast Titanium.app", "Suitcase Fusion 2.app", "Suitcase Fusion 3.app", "Fetch.app"}
    repeat with anApp in theApps
      set vers to version of (application anApp)
      -- get parent path of anApp!!!!
      if (parentFolder is equal to "Applications" or parentFolder is equal to "Utilities") then
      set parentFolder to ""
      end if
      display alert anApp & ": Version: " & vers & " " & parentFolder
    end repeat
    The only thing I'm stuck on is how to get the parent folder of anApp. Basically we use several versions of software here that are not easily identifiable by the version attribute. However their enclosing folder has all the versioning info I need (e.g.: MS Excel 04's vers would be 110113, but the enclosing folder is "Microsoft Office 2004", and some departments get Office 2008, Office 2011, etc., so I need a human-friendly way to get the right versions)
    I don't know if the "if" statement to check whether the parent is Applications or Utilities is correct as I haven't gotten that far in testing. I'm only interested in getting the parent of apps that have parent folder that is a sub-folder of Applications or Utilities.
    Basically what I am trying to do here is write a text file containing all departmental apps, homefolder sizes, relevant partition sizes, etc. and spit it out at the tech responsible for migrating a user to a new mac (display alert is just convenient for testing purposes). In the past we've had too many "missed" items in QC like wrong apps installed, or wrong versions, or data not copied over properly, etc. So this way they can run this on the old system beforehand and the new system after, line everything up and check off if it matches. This is just a snippet...
    TIA!
    Andrew

    Hi,
    Andrew Caldwell wrote:
    Is there a way to invoke these without the script opening each one?
    You must use the bundle identifier instead of the name
    Here a example :
    set theApps to {"com.microsoft.excel", "com.adobe.Acrobat.Pro", "com.barebones.textwrangler", "com.roxio.Toast", "com.fetchsoftworks.Fetch"}
    repeat with anApp in theApps
           tell application "Finder" to tell (application file id anApp)
                  set vers to version
                  set parentFolder to name of its container
           end tell
           if parentFolder is in {"Applications", "Utilities"} then set parentFolder to ""
           display alert anApp & ": Version: " & vers & " " & parentFolder
    end repeat

  • Getting path of parent folder of a file during a workflow execution

    How can I get the parent folder/directory of a file during the execution of a workflow? I cant't find any actions i Automator that will give me this.
    I want to make a general applicable automated workflow. The path can not be hardcoded in the workflow as different files and folders will be worked on each time the workflow is run.
    The input to the workflow is a file or list of files. I want to be able to retrieve the path of the parent folder of these files at runtime.
    Will I have to do this through AppleScript? If so, then how?
    (in case you have seen my first post on this; it seems I wasn't specific enough so people didn't understand what I want to do. Therefore this second post. Sorry for the iconvenience)

    Hi anilsen!
    If all selected files are within the same folder, it would be like this:
    For example:
    • Get Specified/Selected Finder Objects
    • Run AppleScript
    on run {input, parameters}
    tell application "Finder"
    set output to (container of item 1 of input) as alias
    end tell
    return output
    end run
    Spazek

  • How to get the system32 folder path in java?

    how to get the system32 folder path in windows using java code?

    Zstar Electronic Co.Ltd, Wholesaler of fire cards for DS/NDSL/NDSi, Provide R4, R4i, DStt, iEDGE, AK2i,M3,M3i,N5
    www.zstar.hk

  • Get the root folder name once user will upload any files to subfolder with in this root folder using sharepoint designer WF??

    Hi,
    How to get the root folder name using sharepoint designer WF? i have a document library with root folders and subfolders. so i am trying to get the root specific root folder name attaching with email once user will
    upload any files to subfolders within that root folder.
    Thanks in advanced!

    Hi,
    According to your description, you might want to get the root folder name in SharePoint Designer Workflow when there is file uploading.
    The “Path” field of the current item holds the relative path of a file, as a workaround, you can retrieve the value of the “Path” as string, then split the string
    value with a delimiter character of “/” to meet your requirement.
    In SharePoint Designer 2010, there is no OOTB action to split the string. You can use the custom workflow actions below to achieve it.
    Here is a link about the related actions I use in this scenario:
    https://spdwfstringactions.codeplex.com/
    Settings of workflow as below:
    It works well in my environment:
    Best regards
    Patrick Liang
    TechNet Community Support

  • How do I hide the parent folder of the user home folders in File Sharing?

    In 10.6 Server I would set the parent folder so that "Everyone" could not list folder contents, then set "Everyone else" read only.  This prevented the parent folder from showing up in the list of available Share Points and allowing users to see the list of home directories.
    In 10.8, this trick no longer seems to work.  No matter what I set the ACLs to, the folder always shows up as a share point in the connection window.  2014 is the folder I've set for the Home directories of our network users (and there will be 2 more for graduating years.)  I can set the ACL so if they attempt to mount it, it just spits out an error saying they can't view the contents, but that isn't reasonable.  I don't want it to show up at all.  The only thing the students should see is their home folder.  Nothing else.
    What can I do to make it so 2014 doesn't show up in the connection window?  2014 is the parent folder for the home directories, so it can't be unshared.

    This prevented the parent folder from showing up in the list of available Share Points and allowing users to see the list of home directories.
    That second sentence should read:
    This prevented the child folder (parent folder to the home directories) from showing up in the list of available Share Points and allowing users to see the list of home directories.

  • How to get the parent of a component in fx?

    Here is an example:
    Index.fx:
    Stage {
        title: "Online book library";
        width: 1024
        height: 768
        scene:Scene {
        fill: Color.WHITE
        content: [
           banner ,
           login = Login{translateX:715 translateY:135}
    };Login.fx:
    var logOn : Button = Button {
            translateX:25 translateY: 170
            text: "Log On"
            font: Font {size:11 name: "Verdana Bold"}
            action: function() {
                showHello();
    function showHello(){
       // add a label in index.fx whose text is "welcome!";
        }I want to show something on the index.fx but I don't know how to get the parent from the child component?
    In Flex, we use parent or parentApplication, Is there a similar function in JavaFX?

    Reusing the same Tile example, I had no problems, I suppose I was doing wrong the first time:
    def IMAGES_WIDTH = 100;
    def IMAGES_HEIGHT = 100;
    var COLUMN_NB = 3;
    var ROW_NB = 3;
    var scene: Scene;
    var previews: Container;
    Stage
      title: "Test of Tile layout"
      scene: scene = Scene
        width: 500
        height: 500
        fill: Color.LAVENDER
        content:
          previews = Tile
            hgap: 10
            vgap: 10
            layoutX: bind (scene.width - previews.width) / 2
            layoutY: bind (scene.height - previews.height) / 2
            columns: COLUMN_NB
            content: for (i in [ 1 .. COLUMN_NB * ROW_NB ])
              ImageView
                id: "IV{i}"
                image: Image
                  url: "{__DIR__}clock.gif"
                  width: IMAGES_WIDTH
                  preserveRatio: true
                onMousePressed: Hide
    function Hide(evt: MouseEvent): Void
      println("{evt.node} ({evt.node.id}) - {evt.node.parent}");
      var nm: Node = evt.node.parent.lookup("IV5"); // Middle node
      nm.visible = false;
      var ntl: Node = evt.node.parent.lookup("IV1"); //Top left node
      (ntl as ImageView).viewport = Rectangle2D { height: IMAGES_WIDTH/2, width: IMAGES_WIDTH/2 };
      (evt.node.parent as Tile).hgap = 20; // Strange effect, but works
    }

  • On a macbook I purchased secondhand hard drive got corrupted and I started to get the flashing folder with the question mark, I purchased a new hard drive and snow lion install DVD I installed the hard drive and tried disc but kept getting blinking folder

    On a macbook I purchased secondhand hard drive got corrupted and I started to get the flashing folder with the question mark, I purchased a new hard drive and snow lion install DVD I installed the hard drive and tried disc but kept getting blinking folder

    Welcome to Apple Support Communities. We're users here and do not speak for "Apple Inc."
    Power on the computer and insert the DVD immediately.
    Hold down the 'C' key to boot from the Snow Leopard DVD.
    http://support.apple.com/kb/ht1533
    After selecting the appropriate language, if necessary, select Utilities, and Disk Utility.
    You'll likely need to partition and format the new drive before it's recognized.
    http://manuals.info.apple.com/MANUALS/0/MA161/en_US/MacBook_13inch_HardDrive_DIY .pdf
    (Yes, these instructions ARE 7 years old, but the procedure is the same for installing from DVD media.)

  • How to get the parent window in sub-child controller class in javafx?

    how to get the parent window in sub-child controller class in javafx?

    You can get the window in which a node is contained with
    Window window = node.getScene().getWindow();Depending when this is invoked, you might want to check the Scene is not null before calling getWindow().
    If the window is a stage that is owned by another window, you can get the "parent" or "owner" window with
    Window owner = null ;
    if (window instanceof Stage) {
      Stage stage = (Stage) window ;
      owner = stage.getOwner();
    }

  • My edits in LR 5.4 are not showing up on the photos in the parent folder?

    When I open my photos directly from the parent folder on my computer the edits/corrections I made in LR are not showing up, the photos are the original imports?  The photos in the parent folder are renamed as they were in LR.   I'm almost positive the photos in the parent folder showed the edits and corrections prior to LR 5.4.  Does anyone have suggestions?

    That's the way Lightroom works. You will not see the edits you made in Lightroom when viewing your photos via your operating system.
    To see your edits, you need to browse your photos in Lightroom, or if you want to see your edits outside of Lightroom, you must use File->Export in Lightroom to create an exported version of your photo, which will show your edits outside of Lightroom.

  • How to get the parent node of the current node?

    Hi all,
    i want to get the parent node of the current node and the not the parent of the parent node.
    thank you very much

    Hi,
    the parent node of <subnode1-2>29.99</subnode1-2> is (node1), how can do to get <node1> throw <subnode1-2>29.99</subnode1-2> the sub node of <node1>.
    As per my understanding the parent node of <subnode1-2>29.99</subnode1-2> is book not the node1.
    If you want node 1 as a parent of subnode1-2 than your xml will look like this.
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <bookstore>
    <book>
    <fathernode>Harry Potter</fathernode>
    <node1>
           <subnode1>29.99</subnode1>
           <subnode2>29.99</subnode2>
    </node1>
    <node2>
           <subnode1>19.99</subnode1>
           <subnode2>19.99</subnode2>
    </node2>
    </book>
    </bookstore>
    and also if you want tom retrive float data than refer following XPATH.
    "//book[[price='1000']]/price/text()"
    Regards,
    Manoj Bilthare

  • How to get the parent Frame of a component ?

    Hi,
    I'm wondering how to get the parent JFrame (or JDialog) of a component.
    Thanks for tips

    I'm using this code:
    public Component getFrame(Component comp)
        Component frame = comp;
        while ((frame != null) && !(frame instanceof Frame))
            frame = frame.getParent();
        if (frame == null)
            frame = comp;  // no parent found
        return frame;
    }

  • How do you get the Event folder date to match the media dates in FCPX

    Modifying the clip date/time with the Modify command works fine ... but the Event itself still has the date the event was created, not the date of the media that it contains.
    If tried using Touch on the Event folder but FCPX ignores it.
    Any ideas on how to get the Event folder date to match the media dates (or set to any other date desired) so that Events sorted by date show the actual dates of the media that they contain?
    Thanks
    Jonathan

    Here is the texture I've been manipulating  all afternoon to try and achieve the looks i want.
    and when I put this texture over the top of other images and select Multiply, and adjusted the opacity, this is what i get....
    Now this kinda works?? but it still looks not as good on an asian person.
    Thanks by the way to everyone for all the tips, I really really appriciate it   and more suggestions for improvments are welcome!

  • FM for getting the Parent materials for the component material

    Hi All,
             I need to to get a list of parent materials for a given component material and that too upto 10 levels.
    i.e.
    Ist Iteration
    The material M1 is a component in 3 other materials.
    2nd iteration
    The above 3 materials will be a components of 3 other materials each i.e. now a total of 9 materials are there.
    3rd iteration
    The above 9 materials will be a component of 3  other materials each i.e. now a total of 27 materials are there.
    upto 10 iterations.
    Is there any FM which can provide me the list of parent and superparents for a given component material..upto 10 levels (or something closer if these levels exists).
    Regards
    Abhishek

    Hi,
    Check this link..Getting the Parent Material (BOM)

  • Getting the Parent JFrame or JDialog

    I am trying to get the parent JFrame or JDialog so I can change the cursor. Right now I am doing it in a stupid way by doing this:
    private void changeCursorQuestion(){
              JFrame frame=(JFrame) getParent().getParent().getParent().getParent().getParent().getParent().getParent();
              Cursor cursor=new Cursor(Cursor.HAND_CURSOR);
              frame.setCursor(cursor);
         }//end changeCursorQuestionBut is there an easier and of course better way of getting the frame or jdialog that a panel is in?

    I am trying to get the parent JFrame or JDialog so I can change the cursor. You can change the cursor of the JPanel ( in fact any Container) so why use that getParent() thing....
    Also, if you want to have quick refrence to JFrame object from JPanel, extend JPanel to make a new class and have a refrence to that JFrame/JDialog in that class, that way you can access it quickly.
    Thanks!

Maybe you are looking for