eswanborg Posted January 31, 2006 Posted January 31, 2006 (edited) I'm trying to manage a file of media assets. What I'd like to set up (and can't figure out) is a field that will automatically fill, based on the file extension of a file that is batch imported (Import:Folder). So that when I pull in a new batch of images/files, I will have the full filename in one field and then somehow trim or query that filename and fill a second field with just the file extension of that file. Hope that makes sense. Basically I'd like one field with "file.ext" for the name and another that would just show me "ext" as the extension of that file. Thanks. {edit} - just to be clear, the file names are obviously going to vary greatly, so what I'd like to figure out is how to just copy the last three characters from the filename field - as opposed to somehow trimming "X" number of characters from the start of the text. thanks Edited February 1, 2006 by Guest
Raybaudi Posted February 1, 2006 Posted February 1, 2006 Hi assuming that "Picture" is the name of your container field, try this calc for the picture extension: RightWords ( Substitute (RightWords ( GetAsText ( Picture ) ; 1 ) ; "." ; " " ) ; 1 ) this calc will work either with stored images, either with referenced ones. For the picture name try this other: Middle ( GetAsText ( Picture ) ; Position ( GetAsText ( Picture ) ; "/" ; Length ( GetAsText ( Picture ) ) ; - 1 ) + 1 ; Length ( GetAsText ( Picture ) ) )
Raybaudi Posted February 1, 2006 Posted February 1, 2006 That SEEMS beautifull... But isn't a good idea
Zero Tolerence Posted February 1, 2006 Posted February 1, 2006 Custom Function ddsExtension /* David Singleton 10/5/05 To Return the extension of the File, if one exists. */ Let([ a = Middle ( file_name ; Position ( file_name ; "." ; 1 ; PatternCount ( file_name ; "." )); Length ( file_name ) ); b = PatternCount( file_name ; ".")]; If ( b = 0; ""; a)) there are things you must account for: 1. what if the filename has extra .'s in it: file.name.exentsion, f.i.l.e.n.ame.ext 2. What if the extension is longer than 3 characters, what if its 4, or 14? 3. What if there is no extension? (Which is VERY common on the MAC side) The function above will get you the extension, if there is one, no matter what(Or i haven't evern not gotten it back). Being as how your on a MAC, you might want to look into looking at the Creator and filetype also. But I guess it depends on how vigilant you want to be.
Raybaudi Posted February 1, 2006 Posted February 1, 2006 Hi Zero Tolerence i'm assuming you are responding to comment, otherwise do some better trying to my calc ( remember that the picture is Stored or Referenced in a container field)
Zero Tolerence Posted February 1, 2006 Posted February 1, 2006 I will have the full filename in one field... ...so what I'd like to figure out is how to just copy the last three characters from the filename field He has the file name, there is no reason to reference the container field. But, your first function works fine for getting the extension also.
eswanborg Posted February 1, 2006 Author Posted February 1, 2006 Thank you all. I will give these all a try. For the quick fix, the "Right (filename;3)" works for me - thankfully I have control over the files I'm dealing - but having the reference for more complex situations is great - I really appreciate the suggestions and help.
comment Posted February 1, 2006 Posted February 1, 2006 If you do have files with a longer extension or no extension at all, try: Let ( [ len = Length ( FileName ) ; dot = Position ( FileName ; "." ; len ; -1 ) ] ; Case ( dot ; Middle ( FileName ; dot + 1 ; len - dot ) ) )
Recommended Posts
This topic is 6934 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