Answer» Hello - Need some help
I've created a batch file to automatically backup a user's profile and data over the network or onto an external drive. The problem I'm having is that often TIMES a person may have outlook data files (.pst) stored in different PLACES in the C: directory. So i wanted to create a command to search for any .pst files on the c drive, and then if it finds any to then use the xcopy command to move those over to the specified folder on the external drive. So far i can get it to find the files USING attrib but cant seem to connect that to the copy function. Here is an example of what i have at the moment: @echo off :: variables set drive=E:\Backup set backupcmd=xcopy /s /c /d /e /h /i /r /y set search=attrib /s c:\*.pst
echo ### Backing up email and CONTACTS (MS Outlook)... %backupcmd% "%USERPROFILE%\Application Data\Microsoft\Outlook\Default Outlook Profile.NK2" "%drive%\outlook" %backupcmd% "%USERPROFILE%\Application Data\Microsoft\Signatures" "%drive%\Outlook\Signatures" %search%
I know this is probably something really simple that I'm missing here, but i would greatly appreciate any help. ThanksThis may help:
Code: [Select]@echo off :: variables set drive=E:\Backup set backupcmd=xcopy /s /c /d /e /h /i /r /y set search=attrib /s c:\*.pst
echo ### Backing up email and contacts (MS Outlook)... %backupcmd% "%USERPROFILE%\Application Data\Microsoft\Outlook\Default Outlook Profile.NK2" "%drive%\outlook" %backupcmd% "%USERPROFILE%\Application Data\Microsoft\Signatures" "%drive%\Outlook\Signatures"
for /f "tokens=* delims=" %%x in ('dir c:\*.pst /s /b /a') do ( %backupcmd% "%%x" "%drive%\Outlook\..." )
Replace the three dots with the rest of the actual destination directory.
That worked perfectly. THANKS a lot, really appreciate it.
|