October 16, 200619 yr This has got to be the most basic thing but... needing to remove filename suffixes I try: "leftwords ( filename.ai ; 1)" expecting it to return "filename"? but get "filename.ai". I am using "Trim (Substitute (filename; ".ai"; "") to achieve the result but it seems a bit flakey; what if the suffix is .psd for instance?. Any ideas? Edited October 16, 200619 yr by Guest
October 16, 200619 yr I think you need Left(text; Position ( text ; "." ; 1 ; 1 )) You'd replace numOfChars in the Left function with the results of the Position function. HTH
October 16, 200619 yr Author Good one; thanks but you have to put "-1" at the end, otherwise you get the "." - Left ( file name; Position ( file name ; "." ; 1 ; 1 )-1)
October 16, 200619 yr Ha - I always forget that one. But it pointed you in the right direction at least.
October 16, 200619 yr Actually, since file name can contain more than one period (at least in OS X it can), e.g. "MyFile.fp7.zip", it should be: Left ( FileName ; Position ( FileName ; "." ; Length ( FileName ) ; -1 ) - 1 )
October 16, 200619 yr Author yeah, but only if you want to return all bar the last suffix. "guff.guf.guf" yields "guff.guf" hmmm... and leftwords needs a space after the "."
October 16, 200619 yr Your original question was: needing to remove filename suffixes ... expecting it to return "filename" I believe the filename suffix (or more precisely, the filename extension) IS the last suffix - and ONLY the last suffix. Everything bar the last suffix IS the filename. If your requirement is different, please clarify.
Create an account or sign in to comment