Solved

Command or script to find last modified date

Posted on 2011-03-22
12
413 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 52

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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 52

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 52

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

920 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