Delete files from a directory by reading directory report?

Support for xplorer² free lite version

Moderators: fgagnon, nikos, Site Mods

Hadron629
New Member
Posts: 2
Joined: 2010 Sep 21, 11:49

Delete files from a directory by reading directory report?

Post by Hadron629 »

Hello,

I have fond this interesting program and before I install it I want to make sure can it solve my problem. I want to achieve this:

1) I create a directory list (txt report) for a directory. The list contains all the files in the specified directory (including time stamps and all the other file info)

2) after some time (e.g. a month) when the contents of the directory changes I want to compare the actual content of the folder (changed after directory restoration from a DVD-R) with the previously generated directory list report (created before restoration from the DVD-R)

3) all the files in the directory which are NOT in the previously created directory list report have to be DELETED by the program

Is this possible?
If not directly is it possible to create a script? Does the program support scripting?

thank you
User avatar
nikos
Site Admin
Site Admin
Posts: 16297
Joined: 2002 Feb 07, 15:57
Location: UK

Post by nikos »

this is possible but you need the professional xplorer2 and its scrap containers.

first you would load the original folder contents in a scrap pane (eg WIndow menu), then use Actions > Write contents menu command to save a CIDA file with the original contents.

At a later stage, again in a scrap window, double click on this CIDA file and you will get the original contents. Use View > Dual pane to create a dual pane scrap window (if not already so). Drag drop the files from the current folder in the empty scrap pane. Now left you have the original files, right the new stuff. Use Mark > Synchronize panes and all the new files will be hilighted on the right. These are the new files which you can delete from File menu

there are other ways to do this, including importing a text file, but I'm keeping things simple

you can get your free 21 day trial from here
www.zabkat.com/x2down.htm

more tricks and tips, see the demo videos here
www.zabkat.com/x2facts.htm
Hadron629
New Member
Posts: 2
Joined: 2010 Sep 21, 11:49

Post by Hadron629 »

nikos wrote:this is possible but you need the professional xplorer2 and its scrap containers.
.
.
.

there are other ways to do this, including importing a text file, but I'm keeping things simple
Speaking about keeping things simple I have meanwhile solved the problem with two script files (windows batch files) one with 1 line of code and the other with 4 lines of code!

Here they are:

------batch file 1----------

dir "C:<directory1>" >"C:<directory2>\FileList.txt"

--end of batch file 1-------


------batch file 2----------

@echo off
cd "C:<directory1>"
for %%a in (*.*) do (findstr /C:"%%a" "C:<directory2>\FileList.txt" >NUL
if errorlevel 1 del "%%a")

--end of batch file 2-------

<directory1> is the directory which contains files to be checked against the file list report
<directory2> is the directory where the file list report (txt file named "FileList.txt" is placed


Solution:

a) First I click on bat file 1

b) After some time (e.g. after folder initialization from DVD-R) I click on the second bat file which deletes all the files which are not in the file list report created by the first bat file

Try to beat that in simplicity  :wink:
User avatar
nikos
Site Admin
Site Admin
Posts: 16297
Joined: 2002 Feb 07, 15:57
Location: UK

Post by nikos »

if you are into batch files this should be interesting
www.zabkat.com/blog/21Feb10-WSH-browse-subfolders.htm