Hey guys, New to the forums and kinda new with batch in general. Here is my dilemma. I have to first search a computer to see if a .pst file exists, if it does (even if multiples exist) then I need to copy them from one drive to another.
Maybe I'm going about it wrong, but what I'm doing is:
1.) dir /b /s *.pst (to get the output of the directory)
2.) I want to now cd into the directory where they exist and
3.) xcopy from their currentl location to a shared drive (H:\)
I'm missing the bridge connecting 1 to 2 and that's where I was hoping where you guys could help
@echo off
cd\
dir /b /s *.pst
xcopy C:\filepath H:\Outlook_Backup /v /e /k /h /d /y /i
Any suggestions on the essential piece I'm missing?
Outlook backup
Moderator: DosItHelp
Re: Outlook backup
Untested:
If the files are in use then you could get errors.
Code: Select all
@echo off
for /f "delims=" %%a in ('dir c:\*.pst /b /s /a-d ') do (
xcopy "%%a" "H:\Outlook_Backup" /v /e /k /h /d /y /i
)
If the files are in use then you could get errors.
Re: Outlook backup
That did it! I'm using pskill to kill any open outlook sessions and the restarting Outlook at the end of the script. Thanks a million! I still have so much to learn but I'm really enjoying it!
-
- Posts: 1
- Joined: 10 Oct 2012 12:53
Re: Outlook backup
You may Backup and Recover outlook data due to http://www.recoverytoolbox.com/repair_outlook.html
Software works with corrupted .pst up to 32TB
Software works with corrupted .pst up to 32TB
-
- Posts: 233
- Joined: 21 Nov 2010 08:07
- Location: At My Computer
Re: Outlook backup
If you have your batch working and dont want to display any output you can add the following nul command.
Code: Select all
@echo off
for /f "delims=" %%a in ('dir c:\*.pst /b /s /a-d 2^>nul') do (
xcopy "%%a" "H:\Outlook_Backup" /vekhdyi
)
Re: Outlook backup
sourbread wrote:That did it! I'm using pskill to kill any open outlook sessions and the restarting Outlook at the end of the script.
This was from April so is quite an old thread -
but be aware that killing Outlook with pskill or taskkill can damage the Outlook databases.
You would be better off using a different method of closing Outlook, such as send keys or perhaps Autoit to close Outlook gracefully.