Solved

Command or script to find last modified date

Posted on 2011-03-22
12
412 Views
Last Modified: 2012-06-21
We have an old file share that currently has over 250,000 files in it, which we are looking to clear out. Does anyone know a simple batch script or command that can be run to query this directory and the subdirectorys for the files last modified date so that I can put this into a spreadsheet for analysis?
0
Comment
Question by:MartynLawson
12 Comments
 
LVL 5

Expert Comment

by:xylog
ID: 35192200
Forfiles command can do this.
0
 
LVL 43

Accepted Solution

by:
Steve Knight earned 375 total points
ID: 35192849
Try this if you want to do it with a for command and dir (slow!).  Prbably best ran from the server hosting the file share for speed rather than a mapped drive:

@echo off
cd /d c:\sourcedir
dir /s/b > dir.txt

(echo Path,Filename,Size,Date/Time,Attributes
for /f "tokens=*" %%I in ('type dir.txt') do echo "%%~dpI","%%~nxI",%%~zI,%%~tI,%%~aI
)> logfile.csv
start excel logfile.csv
Steve
0
 
LVL 51

Assisted Solution

by:Bill Prew
Bill Prew earned 125 total points
ID: 35195390
Steve, not for points, but how about this slight adjustment.  We can get rid of the first work file, and also I think the poster may want the full file name (with path) all in one cell, so I'm gonna assume that for now.

@echo off
(echo Filename,Date/Time,Size,Attributes
for /f "tokens=*" %%I in ('dir /s/b/a-d x:\folder') do echo "%%~I",%%~tI,%%~zI,%%~aI
)> logfile.csv
start excel logfile.csv

Open in new window

~bp
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 35196206
points neither here nor there bill :-)  i did it with a temporary file as felt sure afyer sitting there running for an hour maybe if someone wanted to re-run because it stopped then cpuld re-run from temp file but  not that useful!

I split out the path and filename so in excel was easier to find all files in one dir etc. If needed, e.g. To turn on sub totals to group by dir. But doesnt hurt to have full path there either - though once in excel could always just copy a formula down.

Main problem is frankly excel will do 64k lines wont it, or maybe that is lifted in newer versions?  if that is the case then would have to split the file every 65000 or so lines or use a VBA macro in excel to read the dir.

Another way and another reason i was going to use a temporary file would be to filter that file using FIND to create say different CSV files for .DOC .XLS :EXE .PPT etc.

Steve
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 51

Expert Comment

by:Bill Prew
ID: 35211767
Newer versions of Excel (2007, 2010) will handle much more than 64k rows.

We'll wait for the poster to provide further feedback and see where it takes us.

Good day,
~bp
0
 
LVL 51

Expert Comment

by:Bill Prew
ID: 35452924
I actually think Steve's post 35192849 provided a workable and acceptable solution, based on the original requirements.

~bp
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 35454522
Me too frankly Bill, but it seems that they only have the option of "delete" in general... always used to ask for opinion and go with what everyone was OK with:

http://www.experts-exchange.com/Community_Support/General/Q_26964168.html?cid=1575#a35453212

Steve
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 35454571
Good by me, thanks!
0
 

Expert Comment

by:Modalot
ID: 35481766
Implementing revised Cleanup Volunteer recommendation.

Modalot
Community Support Moderator
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
This video discusses moving either the default database or any database to a new volume.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now