2 Replies Latest reply on Nov 8, 2012 10:20 AM by Paul Riggott

    Get the folder path and exclude the filename.

    adamfreestyle

      Hi guys,

       

      I am writing a ps script (in javascript) which involves the user navigating to and then selecting a file. The path of the file is then saved to a text file 'path.txt' and is called upon later in the script - for various reasons.

       

      For example:

       

      At the moment, when the file is navigated to and then selected, it will write to the text file:

       

      /h/Art/Textures/MainTexture.tga

       

      Up until now that is what i needed it to do, but now i need a slight modification.

       

      What i need is for it to just write:

       

      /h/Art/Textures

       

      - Excluding the filename.

       

       

      The code that i am currently using for this, is as follows:

       

      UpdatePaths.onClick=function() {

       

           saveFile = File.openDialog("Select the file you are working on:", "All Formats: *.*");

           var txtPath = new File("C:\\path.txt");

           txtPath.open('w');

           txtPath.writeln(saveFile);

           txtPath.close(1);

           fileDialog.close(1);

      };

       

      Hopefully this is just an easy tweak?

       

      Any help would be much appreciated.

       

      Many thanks,

       

      Adam