tachyon Posted October 16, 2006 Posted October 16, 2006 (edited) 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, 2006 by Guest
BronwynL Posted October 16, 2006 Posted October 16, 2006 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
tachyon Posted October 16, 2006 Author Posted October 16, 2006 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)
BronwynL Posted October 16, 2006 Posted October 16, 2006 Ha - I always forget that one. But it pointed you in the right direction at least.
comment Posted October 16, 2006 Posted October 16, 2006 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 )
tachyon Posted October 16, 2006 Author Posted October 16, 2006 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 "."
comment Posted October 16, 2006 Posted October 16, 2006 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.
Recommended Posts
This topic is 6674 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now