HALBURN Posted April 14, 2014 Posted April 14, 2014 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.
doughemi Posted April 14, 2014 Posted April 14, 2014 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.
HALBURN Posted April 14, 2014 Author Posted April 14, 2014 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" )
jbante Posted April 14, 2014 Posted April 14, 2014 Another possibility is this: Let ( [ _fileName = GetValue ( GetAsText ( Table::containerField ) ; 1 ) ; _values = Substitute ( _values ; "." ; ¶ ) ; _count = ValueCount ( _values ) ] ; If ( _count > 1 ; GetValue ( _values ; _count ) ) )
eos Posted April 14, 2014 Posted April 14, 2014 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 ) ) 1
HALBURN Posted April 14, 2014 Author Posted April 14, 2014 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.
HALBURN Posted April 14, 2014 Author Posted April 14, 2014 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.
HALBURN Posted April 14, 2014 Author Posted April 14, 2014 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. :)
Recommended Posts
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