Page 1 of 1

Handling files with quotes

Posted: Mon Jul 16, 2018 4:17 am
by ericnd01
I have a flow that occasionally accepts files with quotation marks in the name. This (obviously) wreaks havoc on scripts and everything else. I thought a good solution would be to use the Rename element to change the quotes to some other string, then revert the name at the end of the flow. The first part works, but when it renames the file back, instead of a quotation mark, it replaces it with an underscore.

I've tried using the "Remember original name" in the first Rename, and replacing the Name Proper with the stored private key, this yielded an underscore.

I tried replacing using a regular expression (", \", and \\") and the replacement doesn't happen.

Any thoughts how I can get the quotation mark back into the filename? I don't have control over the input of the files. Users may submit a file named 5" x 7" print.tif.

Re: Handling files with quotes

Posted: Mon Jul 16, 2018 9:25 am
by jan_suhr
When you first rename the job without quotes, have you tried the property "Remember original name"? It will keep the job name as Private data and then you just rename back to that property value.

Re: Handling files with quotes

Posted: Mon Jul 16, 2018 1:37 pm
by Terkelsen
I have run into this problem before, and I don't think there is any way you can get Switch to rename af ile using a name that includes quotes.

Jan, what you suggest is exactly what ericnd01 is describing, that he already tried ;)

Re: Handling files with quotes

Posted: Mon Jul 16, 2018 1:39 pm
by jan_suhr
Terkelsen wrote: Mon Jul 16, 2018 1:37 pm Jan, what you suggest is exactly what ericnd01 is describing, that he already tried ;)
:o :oops:

Re: Handling files with quotes

Posted: Tue Jul 17, 2018 12:55 am
by ericnd01
Yeah, "Remember original name" does not work. I've tested using explicit names and storing as my own private key and it seems anytime the Rename element is used, it replaces the " with _. I'm going to see if a Script will work any better. I'll let you know what I find out.

Re: Handling files with quotes

Posted: Tue Jul 17, 2018 9:48 pm
by ericnd01
I was able to resolve this using a script:

Code: Select all

function jobArrived( s : Switch, job : Job ) {
    newFile = job.getName().replace("==", "\"" );						
    job.sendToSingle(job.getPath(), newFile);	
}
I use an earlier Rename flow element to change the " to == in the job name. I don't know how well this will work on multi-file jobs (or other caveats), but the application I am using it in seems to work fine. I actually took it further by adding element properties for further customization, but figured I'd keep it simple here.