Delete files from a directory by reading directory report?

Discussion, questions and support.
Post Reply
Message
Author
Quark101
Posts: 2
Joined: 21.09.2010, 13:35

Delete files from a directory by reading directory report?

#1 Post by Quark101 » 21.09.2010, 13:46

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

Quark101
Posts: 2
Joined: 21.09.2010, 13:35

Re: Delete files from a directory by reading directory repor

#2 Post by Quark101 » 22.09.2010, 00:51

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


I am posting this here since there might be other people who have a similar problem so there is a simple solution.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests