I'm trying to write a quick batch file to back up my Outlook 2016 folders (C: drive) to a USB drive (F: drive). It worked for a long time but ever since I reformatted my C: drive, it stopped working. The notepad I use on my desktop (which I click on containing the script) flashes on the my monitor and then flashes of the screen, all in a microsecond.
This is what I've written:
c:
cd C:\Users\digis\Outlook
copy *.* F:\Outlook 2016 back-up folder
Thanks a lot!
Messed-up batch file :(
Moderator: DosItHelp
Re: Messed-up batch file :(
At least your target folder contains spaces and thus, must be enclosed into quotation marks.
untested:
The PAUSE at the end keeps the window opened. Now you can observe error messages. If everything works okay you can remove the PAUSE command.
Steffen
untested:
Code: Select all
@echo off
set "source=C:\Users\digis\Outlook"
set "target=F:\Outlook 2016 back-up Folder"
if not exist "%target%\" md "%target%"
cd /d "%source%"
copy *.* "%target%\"
pause
The PAUSE at the end keeps the window opened. Now you can observe error messages. If everything works okay you can remove the PAUSE command.
Steffen
-
- Posts: 4
- Joined: 31 Dec 2016 19:07
Re: Messed-up batch file :(
aGerman wrote:At least your target folder contains spaces and thus, must be enclosed into quotation marks.
untested:Code: Select all
@echo off
set "source=C:\Users\digis\Outlook"
set "target=F:\Outlook 2016 back-up Folder"
if not exist "%target%\" md "%target%"
cd /d "%source%"
copy *.* "%target%\"
pause
The PAUSE at the end keeps the window opened. Now you can observe error messages. If everything works okay you can remove the PAUSE command.
Steffen
-
- Posts: 4
- Joined: 31 Dec 2016 19:07
Re: Messed-up batch file :(
untested:
[code]
@echo off
set "source=C:\Users\digis\Outlook"
set "target=F:\Outlook 2016 back-up Folder"
----------------------------------------------------------
As I took your suggestion above, didn't work, so i went back and wrote this one:
cd C:\Users\digis\Outlook copy *.*
F:\Outlook 2016 back-up
pause
---and then I get these errors appearing underneath:
C:\Users\digis\Desktop>cd C:\Users\digis\Outlook copy *.*
The filename, directory name, or volume label syntax is incorrect.
C:\Users\digis\Desktop>F:\Outlook 2016 back-up
'F:\Outlook' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\digis\Desktop>pause
Press any key to continue . . .
Hmmmm...
[code]
@echo off
set "source=C:\Users\digis\Outlook"
set "target=F:\Outlook 2016 back-up Folder"
----------------------------------------------------------
As I took your suggestion above, didn't work, so i went back and wrote this one:
cd C:\Users\digis\Outlook copy *.*
F:\Outlook 2016 back-up
pause
---and then I get these errors appearing underneath:
C:\Users\digis\Desktop>cd C:\Users\digis\Outlook copy *.*
The filename, directory name, or volume label syntax is incorrect.
C:\Users\digis\Desktop>F:\Outlook 2016 back-up
'F:\Outlook' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\digis\Desktop>pause
Press any key to continue . . .
Hmmmm...
Re: Messed-up batch file :(
"didn't work" is nothing from what I could ever deduce what happened. Also CD and COPY in the same line can't work and as I already told you pathes with spaces have to be enclosed into quotation marks.
Instead of randomly trying funny things I would like you to
1) Run the script that I provided to you and post the messages that it outputs
2) Check if the pathes are correct and existing
3) Tell me whether or not the files you want to copy are directly placed in C:\Users\digis\Outlook or rather in subfolders.
Steffen
Instead of randomly trying funny things I would like you to
1) Run the script that I provided to you and post the messages that it outputs
2) Check if the pathes are correct and existing
3) Tell me whether or not the files you want to copy are directly placed in C:\Users\digis\Outlook or rather in subfolders.
Steffen
-
- Posts: 4
- Joined: 31 Dec 2016 19:07
Re: Messed-up batch file :(
You were right and I was wrong. This works fine now. Thank you very much!