1 Reply Latest reply on Mar 24, 2008 6:10 PM by (Daniel_Rodney)

    [JS] Need Help Removing File extension (in CS2 and CS3)

      Hello All.

      I have a menu in a dialog that needs to list some file names, but without their file extensions (which will always be .txt in my case). The following is some code that successfully does this in CS3, but I also need it to work in CS2. Do you have any other ways to do this? One code that works in both versions (CS2 and CS3) is ideal.


      myNameWithoutExtensionFunction = function( myNameWithExtention ) {
      myNameWithoutExtension = myNameWithExtention
      myEndOfFileName = myNameWithoutExtension.lastIndexOf( "." )   // get the last period (.) in the filename
      if ( myEndOfFileName > -1 ) {
        myNameWithoutExtension = myNameWithoutExtension.substr( 0, myEndOfFileName )
      }
      return myNameWithoutExtension
      }


      Thanks in advance.
      Dan