Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
qim
- Posts: 15
- Joined: 07 Apr 2014 07:21
#1
Post
by qim » 07 Apr 2014 07:38
Hi
I'm trying to write a batch file to backup some folders but something is not working properly.
OperaMail is not being backed up and i don't understand why. Nor are my images which are in various folders.
Could you tell me, please, where I have gone wrong?
Code: Select all
@echo off
:: variables
set drive=I:\Backup Test
set backupcmd=xcopy /s /c /d /e /h /i /r /y
@pause
echo ### Backing up My Documents...
%backupcmd% "%USERPROFILE%\Documents" "%drive%\Documents"
echo ### Backing up Favorites...
%backupcmd% "%USERPROFILE%\Favorites" "%drive%\Favorites"
echo ### Backing up Desktop...
%backupcmd% "%USERPROFILE%\Desktop" "%drive%\Desktop"
echo ### Backing up email and address book (Outlook Express)...
%backupcmd% "%USERPROFILE%\Application Data\Microsoft\Address Book" "%drive%\Address Book"
%backupcmd% "%USERPROFILE%\Local Settings\Application Data\Identities" "%drive%\Outlook Express"
echo ### Backing up email and address book (Thunderbird)...
%backupcmd% "%USERPROFILE%\AppData\Roaming\Thunderbird\Profiles" "%drive%\Profiles"
echo ### Backing up email and address book (Thunderbird)...
%backupcmd% "%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Libraries" "%drive%\Libraries"
echo ### Backing up email and address book (Opera Mail)...
%backupcmd% "%USERPROFILE%\AppData\Roaming\Opera Mail" "%drive%\Opera Mail"
echo ### Backing up the Registry...
if not exist "%drive%\Registry" mkdir "%drive%\Registry"
if exist "%drive%\Registry\regbackup.reg" del "%drive%\Registry\regbackup.reg"
regedit /e "%drive%\Registry\regbackup.reg"
:: use below syntax to backup other directories...
:: %backupcmd% "...source directory..." "%drive%\...destination dir..."
echo Backup Complete!
@pause
-
Dos_Probie
- Posts: 233
- Joined: 21 Nov 2010 08:07
- Location: At My Computer
#2
Post
by Dos_Probie » 07 Apr 2014 08:16
I assume you are using XP and also copying from your I drive as well, been a while since I used XP but I believe the userprofile, missing your user name, backslash after Documents, directory for you system drive may be PART of your issue try something like this:
PS: for error checking run your code one part at a time with a pause added as well, then go to next section with another pause etc.
Code: Select all
set "I_Usr=I:\Documents and Settings\qim\Documents"
set "cpy=xcopy /scdehiry"
set "drv=I:"
md "%systemdrive%\Documents"
%cpy% "%I_Usr%\*.*" "%drv%\Documents\"
Pause
-
qim
- Posts: 15
- Joined: 07 Apr 2014 07:21
#3
Post
by qim » 07 Apr 2014 08:25
Hi thanks
No, I am using Windows7
Please, note that the batch file is working well except for the OperaMail (The imgs are ok, after all).
Thank you
-
Dos_Probie
- Posts: 233
- Joined: 21 Nov 2010 08:07
- Location: At My Computer
#4
Post
by Dos_Probie » 07 Apr 2014 13:20
qim wrote:Hi thanks
No, I am using Windows7
Please, note that the batch file is working well except for the OperaMail (The imgs are ok, after all).
Thank you
Great, glad you got it working now, you can go ahead then and mark your post as [SOLVED]
DP..

-
qim
- Posts: 15
- Joined: 07 Apr 2014 07:21
#5
Post
by qim » 07 Apr 2014 15:06
Well, it is the OperaMail that was the reason for the post. I cannot understand why it does not work.
-
penpen
- Expert
- Posts: 2009
- Joined: 23 Jun 2013 06:15
- Location: Germany
#6
Post
by penpen » 07 Apr 2014 16:46
Are you sure this is the right folder?
Last time i used Opera (some time ago...) the default directory was just "\Mail"
and not "\Opera Mail".
If i remember right you may view which path was used by doing:
-> Select Help
-> Opera
-> About Opera from the menu in Opera.
-> Look for Mail directory under Paths.
penpen
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#7
Post
by foxidrive » 07 Apr 2014 20:36
Did you close Opera when running the batch file?
What errors do you see on the console if you put a pause after the operamail backup?
-
qim
- Posts: 15
- Joined: 07 Apr 2014 07:21
#8
Post
by qim » 10 Apr 2014 15:37
Hi
many thanks
I followed penpen advice and got Opera mail to get backed up.
meanwhile, I have another problem with that batch file:
The batch file starts like this:
Code: Select all
@echo off
:: variables
set drive=I:\Backup Test
set backupcmd=xcopy /s /c /d /e /h /i /r /y
@pause
echo ### Backing up My Documents...
%backupcmd% "%USERPROFILE%\Documents" "%drive%\Documents"
echo ### Backing up Favorites...
%backupcmd% "%USERPROFILE%\Favorites" "%drive%\Favorites"
echo ### Backing up Desktop...
%backupcmd% "%USERPROFILE%\Desktop" "%drive%\Desktop"
but then I get:
Code: Select all
###backing up My documents
Access denied
Unable to create directory - I:\backuptest\Documents\My music
Acess denied
Unable to create directory - I: \backuptest\Documents\My Pictures
Acess denied
Unable to create directory - I: \backuptest\Documents\My Videos
0 files copied
I don't understand why this is happening.
Thank you
-
Squashman
- Expert
- Posts: 4488
- Joined: 23 Dec 2011 13:59
#9
Post
by Squashman » 10 Apr 2014 17:32
Going to assume you manually typed in that output instead of copying and pasting from the cmd window. Your output doesn't match your batch file code.
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#10
Post
by foxidrive » 10 Apr 2014 19:17
qim wrote:The batch file starts like this:
Code: Select all
@echo off
:: variables
set drive=I:\Backup Test
set backupcmd=xcopy /s /c /d /e /h /i /r /y
@pause
echo ### Backing up My Documents...
%backupcmd% "%USERPROFILE%\Documents" "%drive%\Documents"
echo ### Backing up Favorites...
%backupcmd% "%USERPROFILE%\Favorites" "%drive%\Favorites"
echo ### Backing up Desktop...
%backupcmd% "%USERPROFILE%\Desktop" "%drive%\Desktop"
but then I get:
Code: Select all
###backing up My documents
Access denied
Unable to create directory - I:\backuptest\Documents\My music
Acess denied
Unable to create directory - I: \backuptest\Documents\My Pictures
Acess denied
Unable to create directory - I: \backuptest\Documents\My Videos
0 files copied
I don't understand why this is happening.
It is a permissions error assuming the commands are quite similar to what you have posted.
Right click the batch file and run it as administrator.
-
qim
- Posts: 15
- Joined: 07 Apr 2014 07:21
#11
Post
by qim » 11 Apr 2014 01:56
Hi all
I ran it as administrator ans still got the same result. I am unable to copy paste the results from the command screen. Isn't there a command to output results to file, as there was to printer >prn ?
Thanks
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#12
Post
by foxidrive » 11 Apr 2014 03:07
Is I: drive a network drive, external USB, internal SATA, or what?
To copy the command screen: right click the title bar, select edit, and mark. Then repeat and copy.
-
qim
- Posts: 15
- Joined: 07 Apr 2014 07:21
#13
Post
by qim » 11 Apr 2014 03:31
Hi
"I" is an external drive.
Here goes the results:
Code: Select all
Press any key to continue . . .
### Backing up My Documents...
Access denied
Unable to create directory - I:\Backup Test\Documents\My Music
Access denied
Unable to create directory - I:\Backup Test\Documents\My Pictures
Access denied
Unable to create directory - I:\Backup Test\Documents\My Videos
0 File(s) copied
### Backing up Favorites...
0 File(s) copied
### Backing up Desktop...
0 File(s) copied
### Backing up email and address book (Outlook Express)...
File not found - Address Book
0 File(s) copied
File not found - Identities
0 File(s) copied
### Backing up email and address book (Thunderbird)...
C:\Users\qimi\AppData\Roaming\Thunderbird\Profiles\h6dirckc.default\parent.lock
Sharing violation
0 File(s) copied
### Backing up email and address book (Thunderbird)...
0 File(s) copied
### Backing up email and address book (Opera Mail)...
0 File(s) copied
Press any key to continue . . .
### Backing up the Registry...
Backup Complete!
Press any key to continue . . .
I assume the reason many commands resulted in 0File(s) copies, is due to the fact that this is an incremental backup and I've run it a few times today to emgage in this thread.
Thanks a lot
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#14
Post
by foxidrive » 11 Apr 2014 05:56
How did you run the script as Administrator?
Check these locations:
I:\Backup Test\Documents\My Music - does a file called My Music exist instead of a folder?
I:\Backup Test\Documents\My Pictures - does a file called My Pictures exist instead of a folder?
I:\Backup Test\Documents\My Videos - does a file called My Videos exist instead of a folder?
-
Squashman
- Expert
- Posts: 4488
- Joined: 23 Dec 2011 13:59
#15
Post
by Squashman » 11 Apr 2014 06:15
Those 3 Folders are Junctions put in for legacy purposes. They don't need to be backed up. See what happens when you double click them in Windows Explorer.
You can put in a specific exclude so that Xcopy does not try to back them up. But if you were using Robocopy you could just use the /XJ switch to exclude them.