Handling files with quotes

Post Reply
ericnd01
Newbie
Posts: 15
Joined: Fri Sep 15, 2017 1:17 am

Handling files with quotes

Post 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.
jan_suhr
Advanced member
Posts: 592
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: Handling files with quotes

Post 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.
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
User avatar
Terkelsen
Advanced member
Posts: 298
Joined: Thu Sep 08, 2011 5:08 pm
Contact:

Re: Handling files with quotes

Post 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 ;)
jan_suhr
Advanced member
Posts: 592
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: Handling files with quotes

Post 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:
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
ericnd01
Newbie
Posts: 15
Joined: Fri Sep 15, 2017 1:17 am

Re: Handling files with quotes

Post 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.
ericnd01
Newbie
Posts: 15
Joined: Fri Sep 15, 2017 1:17 am

Re: Handling files with quotes

Post 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.
Post Reply