Robocopy “invalid parameter” for file names beginning with “-” (minus sign)












0















I use robocopy to backup folders and individual files via a batch file. This works fine for all folders and nearly all files, but not for files where the name starts with a "-" (minus sign).



My OS: German Windows 7, 64 Bit. (I don't know if that matters.)



My test batch file does this:



SET fileName=-Test.rar
robocopy "folder 1" "folder 2" "%fileName%"
ECHO Errorlevel: %Errorlevel%


Where %fileName% is quoted because the file name may contain spaces as well.



The result is an ERROR : Invalid Parameter.



-------------------------------------------------------------------------------
ROBOCOPY :: Robustes Dateikopieren für Windows
-------------------------------------------------------------------------------

Gestartet: Wed Nov 21 15:42:47 2018

Quelle - E:BackupThisFilefolder 1
Ziel - E:BackupThisFilefolder 2

Dateien :
Optionen: /COPY:DAT /R:1000000 /W:30

------------------------------------------------------------------------------

FEHLER: Ungültiger Parameter #3 : "-Test.rar"
[...]
Errorlevel: 16


Tested versions of "robocopy.exe":




  • XP010 (Windows XP?)

  • XP026 (Windows 2000?)

  • XP027 Win7 32 Bit

  • XP027 Win7 64 Bit


It always resulted in the same error message or only the equivalent error code 16.



Tested variation of the command:



Then i have tried different variations of the command. Only 1 change (additional quotes) looked remotely promising:



robocopy "folder 1" "folder 2" ""%fileName%""


But it didn't work either:



-------------------------------------------------------------------------------
ROBOCOPY :: Robustes Dateikopieren für Windows
-------------------------------------------------------------------------------

Gestartet: Wed Nov 21 15:43:00 2018

Quelle : E:BackupThisFilefolder 1
Ziel : E:BackupThisFilefolder 2

Dateien : "-Test.rar"

Optionen: /COPY:DAT /R:1000000 /W:30

------------------------------------------------------------------------------

0 E:BackupThisFilefolder 1

------------------------------------------------------------------------------

Insgesamt KopiertÜbersprungenKeine Übereinstimmung FEHLER Extras
Verzeich.: 1 0 1 0 0 0
Dateien: 0 0 0 0 0 0
Bytes: 0 0 0 0 0 0
Zeiten: 0:00:00 0:00:00 0:00:00 0:00:00


Nothing was copied even though the file name parameter was kind of recognized.



I guess that the quotes in the value of the parameter are wrong as well.



Does anyone have an idea?










share|improve this question























  • FYI, I've been able to recreate the problem and have also tried a number of ways around it and have failed. The last test didn't work because you were trying to copy "-Test.rar" and not -Test.rar .

    – Duston
    Nov 21 '18 at 16:45











  • Thank You for testing it. I have seen that "-Test.rar" is not equal to -Test.rar but i hoped that repeated quotes (i tried 3 and 4 as well) would cancel each other out in some way.

    – Futti
    Nov 22 '18 at 6:34











  • FYI: My workaround is to replace the "-" with an "?". This copies at least all files where the name begins with exactly 1 leading char.

    – Futti
    Dec 21 '18 at 8:56
















0















I use robocopy to backup folders and individual files via a batch file. This works fine for all folders and nearly all files, but not for files where the name starts with a "-" (minus sign).



My OS: German Windows 7, 64 Bit. (I don't know if that matters.)



My test batch file does this:



SET fileName=-Test.rar
robocopy "folder 1" "folder 2" "%fileName%"
ECHO Errorlevel: %Errorlevel%


Where %fileName% is quoted because the file name may contain spaces as well.



The result is an ERROR : Invalid Parameter.



-------------------------------------------------------------------------------
ROBOCOPY :: Robustes Dateikopieren für Windows
-------------------------------------------------------------------------------

Gestartet: Wed Nov 21 15:42:47 2018

Quelle - E:BackupThisFilefolder 1
Ziel - E:BackupThisFilefolder 2

Dateien :
Optionen: /COPY:DAT /R:1000000 /W:30

------------------------------------------------------------------------------

FEHLER: Ungültiger Parameter #3 : "-Test.rar"
[...]
Errorlevel: 16


Tested versions of "robocopy.exe":




  • XP010 (Windows XP?)

  • XP026 (Windows 2000?)

  • XP027 Win7 32 Bit

  • XP027 Win7 64 Bit


It always resulted in the same error message or only the equivalent error code 16.



Tested variation of the command:



Then i have tried different variations of the command. Only 1 change (additional quotes) looked remotely promising:



robocopy "folder 1" "folder 2" ""%fileName%""


But it didn't work either:



-------------------------------------------------------------------------------
ROBOCOPY :: Robustes Dateikopieren für Windows
-------------------------------------------------------------------------------

Gestartet: Wed Nov 21 15:43:00 2018

Quelle : E:BackupThisFilefolder 1
Ziel : E:BackupThisFilefolder 2

Dateien : "-Test.rar"

Optionen: /COPY:DAT /R:1000000 /W:30

------------------------------------------------------------------------------

0 E:BackupThisFilefolder 1

------------------------------------------------------------------------------

Insgesamt KopiertÜbersprungenKeine Übereinstimmung FEHLER Extras
Verzeich.: 1 0 1 0 0 0
Dateien: 0 0 0 0 0 0
Bytes: 0 0 0 0 0 0
Zeiten: 0:00:00 0:00:00 0:00:00 0:00:00


Nothing was copied even though the file name parameter was kind of recognized.



I guess that the quotes in the value of the parameter are wrong as well.



Does anyone have an idea?










share|improve this question























  • FYI, I've been able to recreate the problem and have also tried a number of ways around it and have failed. The last test didn't work because you were trying to copy "-Test.rar" and not -Test.rar .

    – Duston
    Nov 21 '18 at 16:45











  • Thank You for testing it. I have seen that "-Test.rar" is not equal to -Test.rar but i hoped that repeated quotes (i tried 3 and 4 as well) would cancel each other out in some way.

    – Futti
    Nov 22 '18 at 6:34











  • FYI: My workaround is to replace the "-" with an "?". This copies at least all files where the name begins with exactly 1 leading char.

    – Futti
    Dec 21 '18 at 8:56














0












0








0








I use robocopy to backup folders and individual files via a batch file. This works fine for all folders and nearly all files, but not for files where the name starts with a "-" (minus sign).



My OS: German Windows 7, 64 Bit. (I don't know if that matters.)



My test batch file does this:



SET fileName=-Test.rar
robocopy "folder 1" "folder 2" "%fileName%"
ECHO Errorlevel: %Errorlevel%


Where %fileName% is quoted because the file name may contain spaces as well.



The result is an ERROR : Invalid Parameter.



-------------------------------------------------------------------------------
ROBOCOPY :: Robustes Dateikopieren für Windows
-------------------------------------------------------------------------------

Gestartet: Wed Nov 21 15:42:47 2018

Quelle - E:BackupThisFilefolder 1
Ziel - E:BackupThisFilefolder 2

Dateien :
Optionen: /COPY:DAT /R:1000000 /W:30

------------------------------------------------------------------------------

FEHLER: Ungültiger Parameter #3 : "-Test.rar"
[...]
Errorlevel: 16


Tested versions of "robocopy.exe":




  • XP010 (Windows XP?)

  • XP026 (Windows 2000?)

  • XP027 Win7 32 Bit

  • XP027 Win7 64 Bit


It always resulted in the same error message or only the equivalent error code 16.



Tested variation of the command:



Then i have tried different variations of the command. Only 1 change (additional quotes) looked remotely promising:



robocopy "folder 1" "folder 2" ""%fileName%""


But it didn't work either:



-------------------------------------------------------------------------------
ROBOCOPY :: Robustes Dateikopieren für Windows
-------------------------------------------------------------------------------

Gestartet: Wed Nov 21 15:43:00 2018

Quelle : E:BackupThisFilefolder 1
Ziel : E:BackupThisFilefolder 2

Dateien : "-Test.rar"

Optionen: /COPY:DAT /R:1000000 /W:30

------------------------------------------------------------------------------

0 E:BackupThisFilefolder 1

------------------------------------------------------------------------------

Insgesamt KopiertÜbersprungenKeine Übereinstimmung FEHLER Extras
Verzeich.: 1 0 1 0 0 0
Dateien: 0 0 0 0 0 0
Bytes: 0 0 0 0 0 0
Zeiten: 0:00:00 0:00:00 0:00:00 0:00:00


Nothing was copied even though the file name parameter was kind of recognized.



I guess that the quotes in the value of the parameter are wrong as well.



Does anyone have an idea?










share|improve this question














I use robocopy to backup folders and individual files via a batch file. This works fine for all folders and nearly all files, but not for files where the name starts with a "-" (minus sign).



My OS: German Windows 7, 64 Bit. (I don't know if that matters.)



My test batch file does this:



SET fileName=-Test.rar
robocopy "folder 1" "folder 2" "%fileName%"
ECHO Errorlevel: %Errorlevel%


Where %fileName% is quoted because the file name may contain spaces as well.



The result is an ERROR : Invalid Parameter.



-------------------------------------------------------------------------------
ROBOCOPY :: Robustes Dateikopieren für Windows
-------------------------------------------------------------------------------

Gestartet: Wed Nov 21 15:42:47 2018

Quelle - E:BackupThisFilefolder 1
Ziel - E:BackupThisFilefolder 2

Dateien :
Optionen: /COPY:DAT /R:1000000 /W:30

------------------------------------------------------------------------------

FEHLER: Ungültiger Parameter #3 : "-Test.rar"
[...]
Errorlevel: 16


Tested versions of "robocopy.exe":




  • XP010 (Windows XP?)

  • XP026 (Windows 2000?)

  • XP027 Win7 32 Bit

  • XP027 Win7 64 Bit


It always resulted in the same error message or only the equivalent error code 16.



Tested variation of the command:



Then i have tried different variations of the command. Only 1 change (additional quotes) looked remotely promising:



robocopy "folder 1" "folder 2" ""%fileName%""


But it didn't work either:



-------------------------------------------------------------------------------
ROBOCOPY :: Robustes Dateikopieren für Windows
-------------------------------------------------------------------------------

Gestartet: Wed Nov 21 15:43:00 2018

Quelle : E:BackupThisFilefolder 1
Ziel : E:BackupThisFilefolder 2

Dateien : "-Test.rar"

Optionen: /COPY:DAT /R:1000000 /W:30

------------------------------------------------------------------------------

0 E:BackupThisFilefolder 1

------------------------------------------------------------------------------

Insgesamt KopiertÜbersprungenKeine Übereinstimmung FEHLER Extras
Verzeich.: 1 0 1 0 0 0
Dateien: 0 0 0 0 0 0
Bytes: 0 0 0 0 0 0
Zeiten: 0:00:00 0:00:00 0:00:00 0:00:00


Nothing was copied even though the file name parameter was kind of recognized.



I guess that the quotes in the value of the parameter are wrong as well.



Does anyone have an idea?







robocopy






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 21 '18 at 16:03









FuttiFutti

54




54













  • FYI, I've been able to recreate the problem and have also tried a number of ways around it and have failed. The last test didn't work because you were trying to copy "-Test.rar" and not -Test.rar .

    – Duston
    Nov 21 '18 at 16:45











  • Thank You for testing it. I have seen that "-Test.rar" is not equal to -Test.rar but i hoped that repeated quotes (i tried 3 and 4 as well) would cancel each other out in some way.

    – Futti
    Nov 22 '18 at 6:34











  • FYI: My workaround is to replace the "-" with an "?". This copies at least all files where the name begins with exactly 1 leading char.

    – Futti
    Dec 21 '18 at 8:56



















  • FYI, I've been able to recreate the problem and have also tried a number of ways around it and have failed. The last test didn't work because you were trying to copy "-Test.rar" and not -Test.rar .

    – Duston
    Nov 21 '18 at 16:45











  • Thank You for testing it. I have seen that "-Test.rar" is not equal to -Test.rar but i hoped that repeated quotes (i tried 3 and 4 as well) would cancel each other out in some way.

    – Futti
    Nov 22 '18 at 6:34











  • FYI: My workaround is to replace the "-" with an "?". This copies at least all files where the name begins with exactly 1 leading char.

    – Futti
    Dec 21 '18 at 8:56

















FYI, I've been able to recreate the problem and have also tried a number of ways around it and have failed. The last test didn't work because you were trying to copy "-Test.rar" and not -Test.rar .

– Duston
Nov 21 '18 at 16:45





FYI, I've been able to recreate the problem and have also tried a number of ways around it and have failed. The last test didn't work because you were trying to copy "-Test.rar" and not -Test.rar .

– Duston
Nov 21 '18 at 16:45













Thank You for testing it. I have seen that "-Test.rar" is not equal to -Test.rar but i hoped that repeated quotes (i tried 3 and 4 as well) would cancel each other out in some way.

– Futti
Nov 22 '18 at 6:34





Thank You for testing it. I have seen that "-Test.rar" is not equal to -Test.rar but i hoped that repeated quotes (i tried 3 and 4 as well) would cancel each other out in some way.

– Futti
Nov 22 '18 at 6:34













FYI: My workaround is to replace the "-" with an "?". This copies at least all files where the name begins with exactly 1 leading char.

– Futti
Dec 21 '18 at 8:56





FYI: My workaround is to replace the "-" with an "?". This copies at least all files where the name begins with exactly 1 leading char.

– Futti
Dec 21 '18 at 8:56












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53416023%2frobocopy-invalid-parameter-for-file-names-beginning-with-minus-sign%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53416023%2frobocopy-invalid-parameter-for-file-names-beginning-with-minus-sign%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

How to fix TextFormField cause rebuild widget in Flutter

Npm cannot find a required file even through it is in the searched directory