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.
Solved! Go to Solution.
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]+'"'
'copy /Y "' + [Source] + '" "' + [Destination] + '"'
That was my original formula, as mentioned in my post.
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:
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.
The output file was configured incorrectely! I left the "Quote output fields" to "Automatic" by mistake.
Nice one @Luke_C - never thought to do it as Flat! Saves some extra config overrides!
Glad you got it sorted out @davidemarcantoni !