Solved

Command or script to find last modified date

Posted on 2011-03-22
12
416 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 53

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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
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
 
LVL 53

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 53

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to use odbc in vb to connect to ms sql 14 62
Chocolatey under PowerShell is not working properly 3 68
VB Script: restart service function 30 38
Problem to cell option 1 36
Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

840 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