How can I do this in Explorer or what program can do this?

For system help, all hardware / software topics NOTE: use Coders Corner for all coders topics.

Moderators: Krom, Grendel

Post Reply
User avatar
Top Wop
DBB Master
DBB Master
Posts: 5104
Joined: Wed Mar 01, 2000 3:01 am
Location: Far from you.
Contact:

How can I do this in Explorer or what program can do this?

Post by Top Wop »

I have a problem. I have a directory structure consisting of 34 GB worth of PDF files. But now I am in a position where I have to take out old files that are'nt being updated anymore. The problem is I dont want to base my deletion on when the folder was created, but when the file inside that folder was last updated. The structure is like this:

A -> Anderson(Folder) -> Inspections.pdf
_____________________ -> Photos.pdf
Andrews(Folder) -> Inspections.pdf
_____________________ -> Photos.pdf

I want to delete Anderson and ANdrews folders based on when the Inspections file was last saved. Since the pdf is updated more recently than when the folder is created, this presents a problem. When I do a search in explorer it ether gives me a listing of pdf files or folders. But I want the empty folders to go with the pdf files, so I need some way to extract the folders based on the last update attribute within that folder.

ANy suggestions or ideas?
User avatar
DCrazy
DBB Alumni
DBB Alumni
Posts: 8826
Joined: Wed Mar 15, 2000 3:01 am
Location: Seattle

Post by DCrazy »

From what I could gather, your files are laid out like this: C:\Wherever\[Letter from A-Z]\[Last Name]\Inspections.pdf. So, the following VBScript will ask for the oldest allowable date and delete all folders whose Inspections.pdf file is older. Save the file, then open it up in notepad and change the line that begins with "sLocation" to point to wherever the letter directories are kept. Then save the script.

Double-click the script to run it. You must have the Windows Scripting Host enabled to run this script -- chances are you probably do. It will ask you for the oldest allowable date. The date can actually be entered in any format you like -- "October 31, 2004" is perfectly valid -- but you're best off sticking to mm/dd/yyyy format. It will then delete all the last-name folders if the Inspections.pdf file is older than the date you entered in the input box. If the script gets confused (it expects to find an Inspections.pdf file but doesn't) it will error out, telling you where it ran into the problem.

Any problems, PM me or post here. Good luck! :D

Richt-Click Save-As (it was unreadable inside the code blocks).
User avatar
Krom
DBB Database Master
DBB Database Master
Posts: 16138
Joined: Sun Nov 29, 1998 3:01 am
Location: Camping the energy center. BTW, did you know you can have up to 100 characters in this location box?
Contact:

Post by Krom »

Make sure you use the "date modified" not the "date created" or "date accessed", you don't wanna get trashed because of something as simple as that.
User avatar
roid
DBB Master
DBB Master
Posts: 9996
Joined: Sun Dec 09, 2001 3:01 am
Location: Brisbane, Australia
Contact:

Post by roid »

personally i'd just use an explorer search, like you did in the past (sort date modified or something). use this to delete all the old files and then use something else to get rid of all of the resulting empty folders.

coz i imagine it's a lot easier to delete empty folders. i commonly see clean-up type programs that go through and delete all the empty folders they find.

DC's way seems pretty cool though


scratch that, i fergot you were making a descinction between the inspections.pdf file and the photos.pdf file. and also that the last-modified date of the photos.pdf file is completely irrelevant.
so my way wouldn't work.
User avatar
Top Wop
DBB Master
DBB Master
Posts: 5104
Joined: Wed Mar 01, 2000 3:01 am
Location: Far from you.
Contact:

Post by Top Wop »

Thanks ill try that out!

Can I modify it to move the folders to another directory rather than deleting?
User avatar
DCrazy
DBB Alumni
DBB Alumni
Posts: 8826
Joined: Wed Mar 15, 2000 3:01 am
Location: Seattle

Post by DCrazy »

Right-Click Save-As

Well, here you go then. Change sLocation to where the files are now, and change sOldFilesLocation to where you want them to end up. There's also an option called bExpandOldFiles that you can use to specify whether you want the old folders to end up as C:\OldFiles\A\Anderson (bExpandOldFiles = True) or just C:\OldFiles\Anderson (= False). Good luck!
Post Reply