Solved Delete files not on a list txt

June 16, 2011 at 05:39:56
Specs: Windows 7, Q9550 / 4 Gig
Hi there!

I need your help by providing the necessary code for Visual Basic that will delete all files in a specific directory that their names are not in a given list.txt file.

Thanks a lot!


See More: Delete files not on a list txt

Report •


✔ Best Answer
June 18, 2011 at 06:37:58
Try using shell "dir *.* > dir.txt",
then process dir.txt.


#1
June 16, 2011 at 13:35:52
You have to compare list,txt with directory.

Report •

#2
June 17, 2011 at 03:06:35
Pardon? Can you be more generous please?

Report •

#3
June 17, 2011 at 16:25:21
Depending on how many files in the list and how many in the directory the methods might vary. I would get a directory list then load it in an array with a flag field. Then compare the file,lst with the directory list, Set the flag for each matching file. Unflagged files are to be deleted.

Report •

Related Solutions

#4
June 18, 2011 at 05:00:55
The number of spare files are unknown and will vary from time to time. I tried the list and array method (with My.Computer.FileSystem.GetFiles) but though it makes the list it doesn't let me declare it as a string for the comparison with the given txt.

But I managed to work it out like this: I add the files that program finds in a temporary txt, proceed comparing 2 txt files and get as a result the spared filed names.


Report •

#5
June 18, 2011 at 06:37:58
✔ Best Answer
Try using shell "dir *.* > dir.txt",
then process dir.txt.

Report •

Ask Question