writting a simple code to back up a file?












0















I am a complete noob but i was able to find this which does what i want. Just backing up a single file with a .bat file.



: variables
set drive=D:backup
SET dateNtime="%date:~0,2%-%date:~3,2%-%date:~6,6%_%time:~0,2%-%time:~3,2%"
set backupcmd=xcopy /s /c /d /e /h /i /r /k /y

echo ### Backing up your Sites directory...
%backupcmd% "d:exampleexample.txt" "%drive%%dateNtime%"

echo Backup Complete - Your Backup is located at %drive%


problem is, when i try to run it as .bat file, this alway alway prop up



D:w10>set drive=D:backup

D:w10>SET dateNtime="31-01-2019_16-38"

D:w10>set backupcmd=xcopy /s /c /d /e /h /i /r /k /y

D:w10>echo ### Backing up your Sites directory...
### Backing up your Sites directory...

D:w10>xcopy /s /c /d /e /h /i /r /k /y "d:exampleexample.txt" "D:backup"31-01-2019_16-38""
Does D:backup31-01-2019_16-38 specify a file name
or directory name on the target
(F = file, D = directory)?


How do i make it automatically select D(or F)?










share|improve this question























  • Possible duplicate : superuser.com/questions/775586/…

    – lx07
    Jan 31 at 17:56











  • Possible duplicate of need to copy folder with sub folder without answering prompt

    – lx07
    Jan 31 at 18:07











  • I tried adding /i at the end of set backupcmd=xcopy /s /c /d /e /h /i /r /k /y /i. but it doesnt copy anymore

    – Sion12 C
    Jan 31 at 18:50













  • Try adding a trailing backslash as described in second option in link above, i.e. %backupcmd% "d:exampleexample.txt" "%drive%%dateNtime%". It worked for me. The option /i only works if you are copying more than one file. See xcopy /? for more info on this.

    – lx07
    Jan 31 at 18:58


















0















I am a complete noob but i was able to find this which does what i want. Just backing up a single file with a .bat file.



: variables
set drive=D:backup
SET dateNtime="%date:~0,2%-%date:~3,2%-%date:~6,6%_%time:~0,2%-%time:~3,2%"
set backupcmd=xcopy /s /c /d /e /h /i /r /k /y

echo ### Backing up your Sites directory...
%backupcmd% "d:exampleexample.txt" "%drive%%dateNtime%"

echo Backup Complete - Your Backup is located at %drive%


problem is, when i try to run it as .bat file, this alway alway prop up



D:w10>set drive=D:backup

D:w10>SET dateNtime="31-01-2019_16-38"

D:w10>set backupcmd=xcopy /s /c /d /e /h /i /r /k /y

D:w10>echo ### Backing up your Sites directory...
### Backing up your Sites directory...

D:w10>xcopy /s /c /d /e /h /i /r /k /y "d:exampleexample.txt" "D:backup"31-01-2019_16-38""
Does D:backup31-01-2019_16-38 specify a file name
or directory name on the target
(F = file, D = directory)?


How do i make it automatically select D(or F)?










share|improve this question























  • Possible duplicate : superuser.com/questions/775586/…

    – lx07
    Jan 31 at 17:56











  • Possible duplicate of need to copy folder with sub folder without answering prompt

    – lx07
    Jan 31 at 18:07











  • I tried adding /i at the end of set backupcmd=xcopy /s /c /d /e /h /i /r /k /y /i. but it doesnt copy anymore

    – Sion12 C
    Jan 31 at 18:50













  • Try adding a trailing backslash as described in second option in link above, i.e. %backupcmd% "d:exampleexample.txt" "%drive%%dateNtime%". It worked for me. The option /i only works if you are copying more than one file. See xcopy /? for more info on this.

    – lx07
    Jan 31 at 18:58
















0












0








0








I am a complete noob but i was able to find this which does what i want. Just backing up a single file with a .bat file.



: variables
set drive=D:backup
SET dateNtime="%date:~0,2%-%date:~3,2%-%date:~6,6%_%time:~0,2%-%time:~3,2%"
set backupcmd=xcopy /s /c /d /e /h /i /r /k /y

echo ### Backing up your Sites directory...
%backupcmd% "d:exampleexample.txt" "%drive%%dateNtime%"

echo Backup Complete - Your Backup is located at %drive%


problem is, when i try to run it as .bat file, this alway alway prop up



D:w10>set drive=D:backup

D:w10>SET dateNtime="31-01-2019_16-38"

D:w10>set backupcmd=xcopy /s /c /d /e /h /i /r /k /y

D:w10>echo ### Backing up your Sites directory...
### Backing up your Sites directory...

D:w10>xcopy /s /c /d /e /h /i /r /k /y "d:exampleexample.txt" "D:backup"31-01-2019_16-38""
Does D:backup31-01-2019_16-38 specify a file name
or directory name on the target
(F = file, D = directory)?


How do i make it automatically select D(or F)?










share|improve this question














I am a complete noob but i was able to find this which does what i want. Just backing up a single file with a .bat file.



: variables
set drive=D:backup
SET dateNtime="%date:~0,2%-%date:~3,2%-%date:~6,6%_%time:~0,2%-%time:~3,2%"
set backupcmd=xcopy /s /c /d /e /h /i /r /k /y

echo ### Backing up your Sites directory...
%backupcmd% "d:exampleexample.txt" "%drive%%dateNtime%"

echo Backup Complete - Your Backup is located at %drive%


problem is, when i try to run it as .bat file, this alway alway prop up



D:w10>set drive=D:backup

D:w10>SET dateNtime="31-01-2019_16-38"

D:w10>set backupcmd=xcopy /s /c /d /e /h /i /r /k /y

D:w10>echo ### Backing up your Sites directory...
### Backing up your Sites directory...

D:w10>xcopy /s /c /d /e /h /i /r /k /y "d:exampleexample.txt" "D:backup"31-01-2019_16-38""
Does D:backup31-01-2019_16-38 specify a file name
or directory name on the target
(F = file, D = directory)?


How do i make it automatically select D(or F)?







command-line






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 31 at 16:50









Sion12 CSion12 C

82




82













  • Possible duplicate : superuser.com/questions/775586/…

    – lx07
    Jan 31 at 17:56











  • Possible duplicate of need to copy folder with sub folder without answering prompt

    – lx07
    Jan 31 at 18:07











  • I tried adding /i at the end of set backupcmd=xcopy /s /c /d /e /h /i /r /k /y /i. but it doesnt copy anymore

    – Sion12 C
    Jan 31 at 18:50













  • Try adding a trailing backslash as described in second option in link above, i.e. %backupcmd% "d:exampleexample.txt" "%drive%%dateNtime%". It worked for me. The option /i only works if you are copying more than one file. See xcopy /? for more info on this.

    – lx07
    Jan 31 at 18:58





















  • Possible duplicate : superuser.com/questions/775586/…

    – lx07
    Jan 31 at 17:56











  • Possible duplicate of need to copy folder with sub folder without answering prompt

    – lx07
    Jan 31 at 18:07











  • I tried adding /i at the end of set backupcmd=xcopy /s /c /d /e /h /i /r /k /y /i. but it doesnt copy anymore

    – Sion12 C
    Jan 31 at 18:50













  • Try adding a trailing backslash as described in second option in link above, i.e. %backupcmd% "d:exampleexample.txt" "%drive%%dateNtime%". It worked for me. The option /i only works if you are copying more than one file. See xcopy /? for more info on this.

    – lx07
    Jan 31 at 18:58



















Possible duplicate : superuser.com/questions/775586/…

– lx07
Jan 31 at 17:56





Possible duplicate : superuser.com/questions/775586/…

– lx07
Jan 31 at 17:56













Possible duplicate of need to copy folder with sub folder without answering prompt

– lx07
Jan 31 at 18:07





Possible duplicate of need to copy folder with sub folder without answering prompt

– lx07
Jan 31 at 18:07













I tried adding /i at the end of set backupcmd=xcopy /s /c /d /e /h /i /r /k /y /i. but it doesnt copy anymore

– Sion12 C
Jan 31 at 18:50







I tried adding /i at the end of set backupcmd=xcopy /s /c /d /e /h /i /r /k /y /i. but it doesnt copy anymore

– Sion12 C
Jan 31 at 18:50















Try adding a trailing backslash as described in second option in link above, i.e. %backupcmd% "d:exampleexample.txt" "%drive%%dateNtime%". It worked for me. The option /i only works if you are copying more than one file. See xcopy /? for more info on this.

– lx07
Jan 31 at 18:58







Try adding a trailing backslash as described in second option in link above, i.e. %backupcmd% "d:exampleexample.txt" "%drive%%dateNtime%". It worked for me. The option /i only works if you are copying more than one file. See xcopy /? for more info on this.

– lx07
Jan 31 at 18:58












0






active

oldest

votes











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
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%2fsuperuser.com%2fquestions%2f1400667%2fwritting-a-simple-code-to-back-up-a-file%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 Super User!


  • 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%2fsuperuser.com%2fquestions%2f1400667%2fwritting-a-simple-code-to-back-up-a-file%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

Сан-Квентин

8-я гвардейская общевойсковая армия

Алькесар