如果我没有记错,PST文件的默认位置是在%localappdata%\Microsoft\Outlook\
。如果用户在多个位置PST文件,它可能是他有不止一个具有相同的名称,只是在不同的文件夹中。美好时光。
如果您的用户有可能在除My Documents
以外的其他位置有PST文件,我建议您修改脚本只做一些非常小的更改。
@echo off
setlocal enabledelayedexpansion
for /r "%userprofile%" %%I in (*.pst) do (
rem avoid overwriting in case "outlook.pst" exists in two locations, for instance
if exist "B:\PST\%username%\%%~nxI" (
set cnt=000
rem get count of files matching b:\pst\username\filename*.pst
for /f %%a in ('dir "B:\PST\%username%\%%~nI*%%~xI" 2^>NUL ^| find " File(s) "') do (
set "cnt=!cnt!%%a"
)
rem file of the same name will become filename001.pst, filename002.pst, etc.
set "dest=%%~nI!cnt:~-3!%%~xI"
rem otherwise leave the filename alone
) else set "dest=%%~nxI"
set /P "=Copying !dest!... "<NUL
copy "%%~fI" "B:\PST\%username%\!dest!"
echo Done.
)
只是出于好奇,有没有使用了'xcopy'而不是原因'copy'? – rojo 2013-03-08 12:39:48