I've some files on a server. I want to keep a current version on my laptop. So far I used the following command in a batch to update my laptop:
xcopy p:\Server f:\Local /S /D /E
Now I've problem how to delete files which are no longer on the server. I get a full list of all unused files with this command:
xcopy f:\local p:\server /l /s /dBut the question now is:
Is there a possibility to delete this files automatically? (I'm using Windows NT)
Thanks for your help,
Christine
Redirect the list to a file like this:
xcopy f:\local p:\server /l /s /d>LISTFILE.TXT
Consider using the /n (generate 8.3 filename format list)
as well if it's available on your system, since it makes it
easier to process the list.
Process the texfile list with FOR /F (type FOR /? for help)
Typical command line in Batch file to process your list:
FOR /F %%V IN (LISTFILE.TXT) DO (ECHO DEL %%V)
Remove the ECHO to activate! when you've satisfied yourself
that the syntax works for you. Note that XCOPY listings may
omit the drive spec. It can be added to %%V. Also note that
XCOPY listings usually have a final multi-[Space] prefixed
filecount. You may wish to filter that line out before processing.
--
(pp) William Allen
For further references, see for example:
Microsoft Windows Shell Scripting and WSH ISBN1-931841-26-8
pages 138 onwards "Processing the Contents of Text Files"
"Christine Volkwein" <christine...@avitech.de> wrote in message news:3C0B3A96...@avitech.de...
If you have the resource kit
ROBOCOPY source_folder destination_folder [file(s)_to_copy] /PURGE
-
Simon Sheppard
Web: http://www.ss64.com
email: Simon@ "
The skript is to hold a documentation local on the laptop and to get
updates.
Christine
The FOR-Loop works very well! :-) I don't know how to filter that
"Count"-Line. Therefor this little "error" is okay for me!
:-) Christine (-:
Tks, Christine
The count line is typically right-justified in a [Space]-filled
field about 9 [Spaces] wide, so all practical filecounts will
contain leading [Spaces]. If you use the /N switch when
doing the List-only XCOPY, you will have only 8.3 names,
so none of the filespecs will contain spaces.
Therefore you can filter the one [Space]-containing-line from
an INPUT.TXT file listing with something like:
find /v " "<INPUT.TXT>OUTPUT.TXT
Type "find /?" for brief help with the FIND filter command.
The /v switch of FIND inVerts the logic and removes all lines
that contain the FIND target string. The same /v switch applies
to the more advanced FINDSTR filter, should you prefer to use that.
--
(pp) William Allen
XXCOPY is a XCOPY-compatible (but boldly extended) file
management utility. It is Freeware for non-commercial users.
What you want to do is basically a one switch operation:
XXCOPY p:\server f:\local /clone
This one line will not only copy all the files that need to be
updated (new files and modified files in the source), it will
remove files from the destination whose counterpart is no longer
present in the source. The /CLONE switch includes operations
/S and /E and /D and more (like /H --- includes hidden/system
files, and /R --- overwrites files that are marked read-only
and lots more).
If you want to confine the action for just removing the
extra files in the destination without copying anything,
you could do so
XXCOPY p:\server f:\local /rx/s/r/h //remove extra files fm dst
XXCOPY is not just a copy utility, it can delete files using
the same rich set of file-selection mechanisms (date, age, size,
name, wildcards, exclude,...).
Unlike Robocopy, XXCOPY is compatible with Win9x/ME/NT/2K/XP.
It also has a 16-bit version, XXCOPY16.
Visit http://www.xxcopy.com
Kan Yabumoto
==============================================================
Christine Volkwein <christine...@avitech.de> wrote in message news:<3C0B3A96...@avitech.de>...
> --