0

I can't find the way to use the Robocopy command for path which has the username & the username has backspace

I want to use a Robocopy command which will work in any profile name. If my username is John & the path of my username is C:\Users\John\ and want to copy an A.txt file which exists in this path to D drive then I should use the below command

ROBOCOPY C:\Users\John\ D:\ A.txt

If now my username is John Papadopoulos then the new command will should be

ROBOCOPY C:\Users\John" "Papadopoulos\ D:\ A.txt and NOT ROBOCOPY C:\Users\John Papadopoulos\ D:\ A.txt because can't read the backspace with this way, only with " ".

If now want to use some general command which work in all occasions such in first with John then we can use the below

ROBOCOPY C:\Users/%username%\ D:\ A.txt but this command works only for first situation and not in second in which username has backspace & is more than one word because if we use this command in second situation then it will be:

ROBOCOPY C:\Users/%username%\ D:\ A.txt which means ROBOCOPY C:\Users\John Papadopoulos\ D:\ A.txt which hasn't " " between John & Papadopoulos and thinks that the Source is C:\Users\John.

*** To say that in above command is " \ " & " % " istead of /% but the comment can't accept the " \ " & " % " together

How to type the command in generic format so that to be C:\Users\John" "Papadopoulos D:\ A.txt ?

Thanks in advance !

Johnn78
  • 1
  • 1

0 Answers0