[<<]Message[>>]    [<<]Author[>>]    [<<]Subject[>>]    [<<]Thread[>>]

Number : 7766 Date : 2004-04-25 Author : John Zeman Subject : Re: Use XXCOPY to Delete Stray Files Size(KB) : 1
--- In xxcopy@yahoogroups.com, "PM" wrote: > Can XCOPY do the following? I have not been able to figure out how but perhaps > someone who is more skilled with the program has some ideas. > > I use a database program that creates a .DAT and a .IDX file for each database I > setup. (For example, ABC.DAT and ABC.IDX) Sometimes when I delete a particular > database it deletes the DAT file but leaves the IDX file. As a result I frequently have > stray IDX files in the directory. Can XXCOPY do either of the following: > > 1. Delete any IDX file for which there is no corresponding (same name) DAT file. > > 2. When I use XXCOPY to copy the directory, don't copy any IDX file for which there > is no corresponding DAT file. > > Thanks. > > Peter Xxcopy would need a little help from a batch file to do this, actually you wouldn't need xxcopy at all for a project like this. The batch file I have below requires NT or newer systems. It will not actually delete anything, it just echoes to the screen what it will delete if you remove the ECHO in the line that begins with IF NOT EXIST. You will want to change the base directory to process the directory you desire. In this example batch file I have the FOLDER variable set to process the c:\test directory. Set FOLDER=c:\test It file will also process all the subdirectories. John :: ========================================== @echo off setlocal @if not "%OS%"=="Windows_NT" goto NT :: SET BASE DIRECTORY TO PROCESS set FOLDER=c:\test for /f "delims=*" %%i in ('dir /a-d/b/s "%FOLDER%\*.idx" 2^> nul') do (call :doit "%%~dpni") pause goto :eof :doit set X=%1 set X=%X:"=% if not exist "%X%.dat" ECHO del "%X%.idx" goto :eof :NT :DOS_EXIT echo This script has aborted because it requires Windows NT echo: echo: echo Press any key to exit pause>NUL exit
This message if part of XXCOPY's message Archive. The archive contains all the messages posted at Yahoo!Groups: XXCOPY.