Solved

Command or script to find last modified date

Posted on 2011-03-22
12
419 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 55

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
The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

 
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 55

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 55

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

690 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