|
Answer» Hey guys,
I'm STARTING to code in DOS and I am having some troubles with the use of variables. I wrote a code to ROBOCOPY a given file to a disk of my choosing using a variable. Here's a shortened version of my code:
set backupdisk=G: robocopy c:\users\... %backupdisk%\documents\backups /E /copyall
Every time I run it, the command prompt interprets it with a space between the variable and the rest of the path (%backupdisk% \documents\backups) so it never works,
Does someone know what's wrong with my code? Thanks!It doesn'tt do that on my system.
Code: [Select]echo off set backupdisk=G: echo robocopy c:\users\... %backupdisk%\documents\backups /E /copyall
Code: [Select]robocopy c:\users\... G:\documents\backups /E /copyall The space is a real character and the set statement takes everything literally. Open your code in an editor and check for a trailing space on the set statement.
Sometimes it's the SIMPLE things,
SidewinderYes. I am so used to my editor (Scite) removing trailing white space when saving I forgot it was possible. I TRIED it with Notepad and got the space in the variable. Hi I CREATED this batch script for incremental and scheduled backup using xcopy command in batch. The first execution of this script is to configure the paths of the source and the destination. And saves them in a .cfg file and then makes a full copy for the first time.
It creates a scheduled task to run every hour with an incremental copy (ie : only copies the new FILES or has been modified from the source).
Incemental Backup.bat
|