4 Replies Latest reply on Sep 22, 2012 8:23 AM by bracke

    Get Parent folder name

    bracke

      Title

      Get Parent folder name

      Post

           Im on a mac, FMP 12 and im at begginer level.

           Hi guys, I need help with a get function. I wanna get the name of the parent folder, not the file name or the file path, just the folder, and if its possible a way to get the name of the next folder up in line. I dont know if there is an easy way to do this. 

           Please help.

        • 1. Re: Get Parent folder name
          philmodjunk

               From what are you getting this info? A container field where the file was inserted with the "Store a reference" option specified?

          • 2. Re: Get Parent folder name
            bracke

                 Yeah, a container field with an image. Usually I import 20 or so images and they all create new records. I can get the file path, the file name, but i cant find a way to get the name of the folder where that file is in, or the name of the folder one step up.

                 EX: /HD/Files/Run 6/John Doe/image.jpeg

                 Thats the path, I need and output for one field to be John Doe and for the another field to be Run 6.

                 Thank you in advance Phil.

                 Please help.

            • 3. Re: Get Parent folder name
              philmodjunk

                   The key trick is to use negative numbers to use position to search your text from right to left.

                   Let ( [ path = getAsText ( yourtable::yourcontainerField ) ;
                            Lp = Length ( path ) ;
                            Sl1 = position ( path ; "/" ; Lp ; -1 ) ;
                            Sl2 = position ( path ; "/" ; Lp ; -2 ) ;
                           ] ;
                            Middle ( path ; Sl2 + 1 ; Sl1 - Sl2 - 1 )
                           )

                   Will return John Doe

                   Let ( [ path = getAsText ( yourtable::yourcontainerField ) ;
                            Lp = Length ( path ) ;
                            Sl2 = position ( path ; "/" ; Lp ; -2 ) ;
                            Sl3 = position ( path ; "/" ; Lp ; -3 ) ] ;
                            //Middle ( path ; Sl3 + 1 ; Sl2 - Sl3 - 1 )
                           )

                   Will return Run 6

              • 4. Re: Get Parent folder name
                bracke

                     Thank you so much Phil, it worked like a charm!