Join the Alteryx Community’s Maveryx Summer Cup event! Compete, network with others, and earn your gold through a series of challenges from July 24th to August 11th. Learn more about the event here.

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Path-like string for batch command created via Formula gets escaped twice

davidemarcantoni
5 - Atom

I need to run the copy MSDOS command using the Run Command tool. Since both arguments are path objects, I need to escape them using the double quotes. To do that, I use the following Formula:

 

'copy /Y "' + [Source] + '" "' + [Destination] + '"'

 

On the output of the formula, I correctly see copy /Y "C:\...\..." "C:\---\---"

However, when I take a look at the batch file that is created on the hard drive, I see the following

 

Command

"copy /Y ""C:\...\...\"" ""C:\---\---\"""

 

As you can see, there are extra double quotes pairs which are enclosing the whole command, the source and destination paths. I have no idea why they are created.

I also tried the following

'copy /Y ' +'"'+[Source] + '"'+" "+ '"' + [Destination]+'"'

with equal effects.

 

The only thing that works is having no escaping, thus

"copy /Y " + [Source] + " "+ [Destination]

which produces

 

Command

copy /Y C:\...\...\ C:\---\---\

 

which, again, works but may not always do so.

 

I am currently on version 2021.4 and Windows 11.

EDIT: Following @mbarone suggestion, I have added colors to single and double quotes to better read the thread.

7 REPLIES 7
mbarone
16 - Nebula
16 - Nebula

Gets tricky with the single vs. double quotes.

 

Here's my formula that works fine (single=blue; double=red).  Here, I'm copying a log file from it's orig location (created path by formula) on the Server to a Destination folder (also created path by formula).

 

'copy "'+[Orig_Log_Path]+'" "'+[Destination_Folder]+'"'

davidemarcantoni
5 - Atom

'copy /Y "' + [Source] + '" "' + [Destination] + '"'

 

That was my original formula, as mentioned in my post. 

mbarone
16 - Nebula
16 - Nebula

It's hard to distinguish in your post which quotes are which with them being the same color . . . 

 

What's your output tool (or your Write Source Output Template in the Run Command Tool) look like?  Make sure it's like this:

 

2022-03-23 09_32_02-Alteryx Designer x64 - Log_Extraction.yxwz.png

 

 

Luke_C
17 - Castor

Hi @davidemarcantoni 

 

Similar to @mbarone, I usually set it up like this to avoid dealing with the quote configurations (Flat ASCII vs CSV). Haven't ran into any issues like you describe.

Luke_C_0-1648042786932.png

 

davidemarcantoni
5 - Atom

The output file was configured incorrectely! I left the "Quote output fields" to "Automatic" by mistake.

mbarone
16 - Nebula
16 - Nebula

Nice one @Luke_C  - never thought to do it as Flat!  Saves some extra config overrides!

mbarone
16 - Nebula
16 - Nebula

Glad you got it sorted out @davidemarcantoni !

Labels