April 14, 201411 yr How can I grab the file extension from a file that is placed into a container field? Example of file names in my containers: sales.report.2014.pdf company.web-logo.svg poster1.01-36.jpeg t-shirt_2.06-hr1.jpg My ultimate goal is to rename them and I want to make sure that the correct extension gets added to the new name.
April 14, 201411 yr Try this calc: Let( [url= GetAsText(YourContainerField); lastdot = PatternCount ( url ; "." ); lastdotpos=Position(url; ".";1;lastdot); urllength=Length(url) ]; Right(url; urllength-lastdotpos) ) This presumes that the files are not externally stored.
April 14, 201411 yr Author Thanks. The file is externally stored. Can you please tell me what I would I need to change in your formula? I am trying to get the file name using this calculation but it's not working. It returns a question mark. GetContainerAttribute ( myContainerField ; "filename" )
April 14, 201411 yr Another possibility is this: Let ( [ _fileName = GetValue ( GetAsText ( Table::containerField ) ; 1 ) ; _values = Substitute ( _values ; "." ; ¶ ) ; _count = ValueCount ( _values ) ] ; If ( _count > 1 ; GetValue ( _values ; _count ) ) )
April 14, 201411 yr Try this calc: [ … ] This presumes that the files are not externally stored. Or this one: Let ( url = Substitute ( GetAsText ( YourContainerField ) ; "." ; ¶ ) ; RightWords ( url ; 1 ) ) EDIT: For v13, use Let ( a = GetContainerAttribute ( yourContainerField ; "filename" ) ; RightWords ( Substitute ( a ; "." ; ¶ ) ; 1 ) )
April 14, 201411 yr Author Thanks guys. This worked for me: Let ( a = GetContainerAttribute ( yourContainerField ; "filename" ) ; RightWords ( Substitute ( a ; "." ; ¶ ) ; 1 ) ) I also discovered that GetContainerAttribute ( myContainerField ; "filename" ) was originally not working because my calculation was being stored. jbante, I tried to use your formula but it kept telling me that "_values" could not be found and I was not sure how to resolve that.
April 14, 201411 yr Author Do either of you know how to change the name of a remote container image that is being stored on a FileMaker 12 Advanced server? I am trying to do this from a Mac running FMPA 13. This seems a bit tricky to pull off. I think the best bet may be fore me to save the container image with the new name to my computer and then replace the current container image with the new one.
April 14, 201411 yr Author I ended up creating a looping script that saved the files to a local folder and then replaced the remote container contents with the newly renamed image file. A little slow but it got the job done. :)
Create an account or sign in to comment