step Posted April 23, 2012 Share Posted April 23, 2012 I have the following code in which I'm attempting to name the output file as "internal job number" + "client's csv file name" + ".pdf" extension. And for some reason the result is just the "client's csv file name + the .pdf extension – disregarding the static text prefix. Is this a known issue with 7.2? I have had success doing this in the past before upgrading. Any ideas? var input = FusionPro.Composition.inputFileName; var file = input.split("."); FusionPro.Composition.outputFileName = "143340-1_" + file[0] + ".pdf"; Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted April 23, 2012 Share Posted April 23, 2012 FusionPro.Composition.inputFileName returns the full path of the input file, which starts with a slash on Mac. You're effectively telling it to look for a file like "143340-1_/some path on your Mac/filename.pdf", which of course doesn't exist. So it ignores the path and just uses the file name. You want to use the GetFileName function to strip off the path, like so: var input = GetFileName(FusionPro.Composition.inputFileName);Also, the way you're removing the extension from the file name won't properly handle the case where the name contains more than one dot (like "joe.smith.txt"). You can use the ReplaceFileExtension function instead to handle this. So the rule then becomes: FusionPro.Composition.outputFileName = "143340-1_" + ReplaceFileExtension(GetFileName(FusionPro.Composition.inputFileName), "pdf"); Quote Link to comment Share on other sites More sharing options...
step Posted April 23, 2012 Author Share Posted April 23, 2012 Excellent! Thanks for the quick reply, Dan! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.