My robocopy sync button is not working if space in path

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
brontosaurusrex
Junior Member
Junior Member
Posts: 16
Joined: 2021-01-01, 17:56 UTC

My robocopy sync button is not working if space in path

Post by *brontosaurusrex »

Trying to do a little robocopy sync button, what I have

Code: Select all

Command: powershell -NoExit -Command robocopy
Parameters: %P %T /E /xd "Adobe Premiere Pro*"
is working as long as there are no spaces in (%P and %T) path names..., how would I quote correctly to include that option as well?

edit: Changing the button to use cmd behaves the same

Code: Select all

Command: cmd /K
Parameters: echo %P %T && robocopy %P %T /E /xd Adobe*Premiere*Pro*
edit2: Similar problem when cmd and powershell are excluded, I have this button for 'windows terminal preview'

Code: Select all

Command: wt
Parameters: -d %P
on folder named 't m p 2' returns

Code: Select all

[error 0x80070002 when launching `m p 2\']
Reading similar threads on this forum is giving me no clues on what the solution might be. Using Windows 10, 64bit, Total Commander Version 9.51 64 bit.
hi5
Power Member
Power Member
Posts: 551
Joined: 2012-11-03, 11:35 UTC
Contact:

Re: My robocopy sync button is not working if space in path

Post by *hi5 »

Try adding quotes around the variables like so "%P" "%T%"
F4MiniMenu (Forum) - Open selected file(s) from TC in defined editor(s) - A (minimalistic) clone of F4Menu
Source at GitHub (AutoHotkey). TCSyncComments (copy file comments)
User avatar
brontosaurusrex
Junior Member
Junior Member
Posts: 16
Joined: 2021-01-01, 17:56 UTC

Re: My robocopy sync button is not working if space in path

Post by *brontosaurusrex »

Obviously I tested every possible version of quotes, no quotes, single quotes as well (forgot to mention). @hi5, Did you test your proposal?
User avatar
nsp
Power Member
Power Member
Posts: 1805
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Re: My robocopy sync button is not working if space in path

Post by *nsp »

Hi,

You can have some issue when quoting single parameter only. i.e. "%P" or "%T" you also add some difficulties using intermediate command interpreter.
You can try:

Code: Select all

command:cmd /k
parameters:echo '%P' to '%T'&robocopy "%P\." "%T\." /E /xd Adobe*Premiere*pro

Code: Select all

command: powershell -NoExit -Command
parameters:robocopy '%P\.' '%T\.' /E /xd Adobe*Premiere*pro
Use " with cmd and ' with powershell.

Source folder is . as by default execution starts in current folder so usually no need to use %P in such button !
User avatar
brontosaurusrex
Junior Member
Junior Member
Posts: 16
Joined: 2021-01-01, 17:56 UTC

Re: My robocopy sync button is not working if space in path

Post by *brontosaurusrex »

@nsp, beautiful, thanks, got it to work!
p.s. Any explanation on why \. is needed?
User avatar
Hacker
Moderator
Moderator
Posts: 13065
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: My robocopy sync button is not working if space in path

Post by *Hacker »

brontosaurusrex,
Might work even with only

Code: Select all

\"
(without the dot)

HTH
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
brontosaurusrex
Junior Member
Junior Member
Posts: 16
Joined: 2021-01-01, 17:56 UTC

Re: My robocopy sync button is not working if space in path

Post by *brontosaurusrex »

@hacker: I'am guessing this 'signals without any doubt' that the directory\ is in question? (And yes, it is working)
User avatar
Hacker
Moderator
Moderator
Posts: 13065
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: My robocopy sync button is not working if space in path

Post by *Hacker »

brontosaurusrex,
Well, more or less yes, I think when you have
"c:\dir\"
then the last \ escapes the " thus makes it not the end of the parameter but a literal quote sign, so the program sees c:\dir" instead of c:\dir\
The additional \ makes a double slash appear at the end, so it is "c:\dir\\" which escapes the last \ (makes it literal) so that the last \ does not escape the " and thus it keeps its function of ending the parameter and the program sees c:\dir\ correctly. Anyone correct me if I am wrong.

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
Dalai
Power Member
Power Member
Posts: 9389
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: My robocopy sync button is not working if space in path

Post by *Dalai »

2Hacker
Correct. I can remember that a similar topic was discussed in the past, but not sure when.

Grüße
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
Post Reply