2 Replies Latest reply on Aug 27, 2007 6:28 AM by tedalde2

    how to get file name on the base of extension

    farhanakhan Level 1
      hi

      reply me

      how to get the filename on the base of extension from the current directory......

      for example

      i create file with the "igg" extension and save in the folder where the exe file of director save....
      i want when exe run then exe file read filename of the define( "igg" ) extension with out path just name of the file with igg extension
      tel me how

      regards
      farhana khan
        • 1. how to get file name on the base of extension
          James Newton, ACP Level 3
          Here's a solution that requires no xtras:

          on GetFilesWithExtension(aFolderPath, aExtension) --------------------
          -- INPUT: <aFolderPath> should be a valid string folder path
          -- <aExtension> may be a string file extension, without the
          -- dot. For example: "txt" or "igg"
          -- OUTPUT: Returns an error symbol or a linear list of file names
          -- in the given folder. If an extension is given, only
          -- files with the given extension will be listed. If not,
          -- all files and folders will be listed.
          --------------------------------------------------------------------

          vFileList = []

          if not stringP(aFolderPath) then
          return #stringPathExpected
          end if

          vIgnoreExtension = not stringP(aExtension)

          vDelimiter = the itemDelimiter
          the itemDelimiter = "."

          n = 0
          repeat while TRUE
          n = n + 1
          vFileName = getNthFileNameInFolder(aFolderPath, n)
          if vFileName = "" then
          exit repeat
          end if

          if vIgnoreExtension then
          vFileList.append(vFileName)
          else if the last item of vFileName = aExtension then
          vFileList.append(vFileName)
          end if
          end repeat

          the itemDelimiter = vDelimiter

          return vFileList
          end GetFilesWithExtension



          You can also use Buddy API's baFileList, which allows you to do wildcard searching.