Solved

to find files in dos

Posted on 2008-10-05
4
814 Views
Last Modified: 2011-09-20
I want to search files in dos by age or last modified time .I want it in a form of a script and not using windows search option in the start menu...For example I want to find all the files that are more than one month old and which are greated than 5 Mb and delete them.. Thanks in advance..
0
Comment
Question by:conversekid
[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
4 Comments
 
LVL 5

Assisted Solution

by:Didier Vally
Didier Vally earned 100 total points
ID: 22647618
Try this link with a lot of useful examples of VBS scripts that will help you :
http://www.scriptinganswers.com/vault/Files%20and%20Folders/
0
 

Author Comment

by:conversekid
ID: 22647732
Thanks but I require in dos scripting ..Thanks
0
 
LVL 26

Accepted Solution

by:
farhankazi earned 200 total points
ID: 22648977
Try following command line statement.
You may need "FORFILES.exe" (comes with Windows 2000 Resource Kit & Vista)

Windows 2000 Resource Kit:
http://www.petri.co.il/download_free_reskit_tools.htm

Following statement will find *.log file in C: drive that modified over 100 days ago and are greater then 5 MB.

Click Start -> Run -> Cmd.exe -> Copy & Paste below statement on command prompt

Hope this helps!
Farhan



FOR /F "tokens=1-2*" %a IN ('FORFILES -pc:\ -m*.log -d-100 -c"Cmd.exe /C @ECHO @FSIZE @FILE"') DO @IF %a GEQ 5242880 @ECHO %b %a

Open in new window

0
 
LVL 31

Assisted Solution

by:Paranormastic
Paranormastic earned 200 total points
ID: 22669754
Another option using robocopy (comes with server 2003):
robocopy %sourcedir% %destdir% %file(s)% /S /ZB /COPYALL /MOVE /MINLAD:31 /V > robocopy_%date:~10,4%_%date:~4,2%_%date:~7,2%.log

this would move files and delete the old ones from sourcedir to destdir - if you do not specify files then all would be included.  includes subfolders, copying in restartable/backup mode (if it cannot be currently accessed), and instead of using last modified date would look at the last accessed date, which might be more desirable.  

You can run with /L to just list what would be done without doing it
You can use /XF to exclude file types that you do not want to move (e.g. /XF *.mp3) - we did this when moving user directories from one file server to another, they were not supposed to have movies, music, etc. stored on their share drive.  This could also be found with dir /s *.mp3 > mp3.log  to list and then go through and delete via batch script easily created from the output ;)

Note that if you run in a mixed environment with non-windows boxes this can be nice as it will not err out if a mac or linux box created a file with a space after the end of the extension or used other normally invalid characters not allowed by a regular copy function.
0

Featured Post

Veeam gives away 10 full conference passes

Veeam is a VMworld 2017 US & Europe Platinum Sponsor. Enter the raffle to get the full conference pass. Pass includes the admission to all general and breakout sessions, VMware Hands-On Labs, Solutions Exchange, exclusive giveaways and the great VMworld Customer Appreciation Part

Question has a verified solution.

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

VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

630 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