How do you handle Illegal Characters?

Post Reply
cwswitch
Member
Posts: 78
Joined: Fri Feb 24, 2017 12:25 am

How do you handle Illegal Characters?

Post by cwswitch »

Illeg&ampl Ch&amprachters

How do you guys handle files with funny characters in them please?

My fail point is when I inject. First there is an error that the file does not exist, followed by a later error that my xml is now orphaned.

The issue each time is a funny character, like an "&" in the file name.
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: How do you handle Illegal Characters?

Post by gabrielp »

Here is a script that scrubs them from private data variables: https://github.com/open-automation/swit ... e-scrubber
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
cwswitch
Member
Posts: 78
Joined: Fri Feb 24, 2017 12:25 am

Re: How do you handle Illegal Characters?

Post by cwswitch »

Thanks

Your forum posts and scripts are very clear and useful. I could not get by without your private data script! I use that all the time for sorting jobs.

I'm a bit unclear how I use this for injecting a job with an "&" in the filename

Example error I'm trying to work around

Code: Select all

Error,Inject job,141032.01.xml,Failed to inject job: file or folder 'foo\141032.01\A5 SPEND&SAVE - final.pdf' does not exist
jan_suhr
Advanced member
Posts: 591
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: How do you handle Illegal Characters?

Post by jan_suhr »

If the problematic characters are in the filename and Switch has problem finding the files Switch can't change the file name until the file is in the Switch system.

What are the file systems? Are the files on another system than the Switch installation?


Jan
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
cwswitch
Member
Posts: 78
Joined: Fri Feb 24, 2017 12:25 am

Re: How do you handle Illegal Characters?

Post by cwswitch »

Thanks,

Very good point that Switch can't work on files it can't find.. I feel silly for even considering that!

The files are on a Windows Server which I access over the network.

I suppose I was wondering whether I could manipulate the XML or pull the path into Private Data (as Gabriel seemed to be suggesting) then clean it up and try my Inject.

Switch is saying

Code: Select all

Failed to inject job: foo/bar&baz.pdf' does not exist
I guess Gabriel is saying to pull the file path into a Private Data key, clean it, then call the Inject with the clean path - but I'm at loss to how.
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: How do you handle Illegal Characters?

Post by gabrielp »

cwswitch wrote: I guess Gabriel is saying to pull the file path into a Private Data key, clean it, then call the Inject with the clean path - but I'm at loss to how.
I would probably aim to figure out how the files are getting there in the first place, then have Switch do that, cleaning the file names before I archive them. Then later on, they can be injected more easily.

Code: Select all

Failed to inject job: foo/bar&baz.pdf' does not exist
I'm guessing that you're getting this value from an XML dataset or something. So I bet if you wrote a script to decode HTML entities, you could then use the normal inject to get these files.
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
jan_suhr
Advanced member
Posts: 591
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: How do you handle Illegal Characters?

Post by jan_suhr »

Shouldn't Switch decode the XML, the & is illegal in XML and is written as &. If you get it from a Metadata variable it should be correctly applied as a file path in Switch. If not you always have the Search field in the variables were you can do a RegEx to change the & to & and then the path should work.


Jan
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
Post Reply