Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi guys,
Can anyone help me with a batch file that searches a drive for .pst and .dbx files through all dirs, then copies the files it found to a directory?
thanks heaps ,
Mike

try this,
dir C:\*.pst /s /b > C:\files.log
dir C:\*.dbx /s /b >> C:\files.logand then .. hmm, use some editing program to use this file as input to create a batchfile to copy the files to the same dir
thats the way I would do it, edting can be done with awk (non-DOS program)

Miskva is right about getting the list, but Edwin suggested a solution which I don't know if works, but is definitively dependent on a 3rd party application. That means it won't run in most of the regular Win98 systems, unless you include the 3rd party program together.
That's not necessary. Here's a solution which won't need any 3rd party apps, so should work on most Win98 systems:
===== BATCH SCRIPT BEGIN =====
@echo offset DEST=X:\Anywere
set DIRBAK=%DIRCMD%
set DIRCMD=
dir/b/s/a-d \*.pst > %TEMP%.\T1.BAT
dir/b/s/a-d \*.dbx >> %TEMP%.\T1.BAT
set DIRCMD=%DIRBAK%
set DIRBAK=echo e100'SET %%1='> %TEMP%\T3.DAT
for %%? in (rcx 7 w q) do echo %%?>> %TEMP%.\T3.DAT
type nul> %TEMP%.\T2.DAT
DEBUG %TEMP%.\T2.DAT < %TEMP%.\T3.DAT > nul:loop
copy %TEMP%.\T1.BAT nul > %TEMP%.\T3.DAT
FIND " 0 " < %TEMP%.\T3.DAT > nul
if not errorlevel=1 goto loopend
copy/y %TEMP%.\T2.DAT+%TEMP%.\T1.BAT %TEMP%.\T3.DAT > nul
FIND "SET %%1=" < %TEMP%.\T3.DAT > %TEMP%.\T1.BAT
call %TEMP%.\T1.BAT FILEcopy %FILE% %DEST%
FIND/V "SET %%1=" < %TEMP%.\T3.DAT > %TEMP%.\T1.BAT
goto loop:loopend
for %%? in (T1.BAT T2.DAT T3.DAT) do del %TEMP%.\%%?
set DEST=
:eof
===== BATCH SCRIPT END =====That script was extracted from my FAQ #24.
-- Leonardo Pignataro - Secret_Doom --
PS: Hey, Miskva, see the checking for the zero-byte file? =D
secret_doom@hotmail.com
www.batch.hpg.com.br_____________________________________________________________________

Hey, I just tested the script and found out a bug, besides the fact that you could run out of enviroment space. Here's the script with the error corrected and which will get more enviroment space:
===== BATCH SCRIPT BEGIN =====
@echo off
if "%1"=="GoTo" goto %2
%comspec% /e:4096 /c %0 GoTo start
goto eof
:startset DEST=X:\Anywere
set T1=%TEMP%.\T1.BAT
set T2=%TEMP%.\T2.DAT
set T3=%TEMP%.\T3.DAT
set DIRCMD=
dir/b/s/a-d \*.pst > %T1%
dir/b/s/a-d \*.dbx >> %T1%
echo e100'SET %%1='> %TEMP%\T3.DAT
for %%? in (rcx 7 w q) do echo %%?>> %T3%
type nul> %T2%
DEBUG %T2% < %T3% > nul:loop
copy %T1% nul > %T3%
FIND " 0 " < %T3% > nul
if not errorlevel=1 goto loopend
copy/y %T2%+%T1% %T3% > nul
FIND "SET %%1=" < %T3% > %T1%
call %T1% FILEcopy "%FILE%" "%DEST%"
FIND/V "SET %%1=" < %T3% > %T1%
goto loop:loopend
for %%? in (%T1% %T2% %T3%) do if exist %%? del %%?:eof
===== BATCH SCRIPT END =====That script was designed and tested under Win98SE. It will fail under NT systems. The script won't copy hidden files.
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br_____________________________________________________

Thanks. I've found another error: where it says
echo e100'SET %%1='> %TEMP%\T3.DAT
Should be
echo e100'SET %%1='> %T3%
The script still works if T3=%TEMP%.\T3.DAT, but that affects the logic of the script.
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |