Solved

Command or script to find last modified date

Posted on 2011-03-22
12
417 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 54

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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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 54

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 54

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

733 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