Solved

to find files in dos

Posted on 2008-10-05
4
807 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
4 Comments
 
LVL 5

Assisted Solution

by:Didier Vally
Didier Vally earned 100 total points
Comment Utility
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
Comment Utility
Thanks but I require in dos scripting ..Thanks
0
 
LVL 26

Accepted Solution

by:
farhankazi earned 200 total points
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video discusses moving either the default database or any database to a new volume.

763 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

12 Experts available now in Live!

Get 1:1 Help Now