Solved

Move files that fall within a date range

Posted on 2006-11-20
7
5,075 Views
Last Modified: 2007-12-19
Help!  Here's my situation.  On my Windows Server 2003 box, I have a folder that has so many files that I can now longer browse to it.  I need to move files that were created between July 1, 2005 - June 30, 2006 to a different location.  I have to use DOS commands to accomplish this but my "DOS for Dummies" reference book (which had to be dusted off) doesn't provide me any clue on how to accomplish this.

THANKS!!
0
Comment
Question by:dalexan12456
7 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 total points
ID: 17981910
While you could probably accomplish this with a batch solution, I'd suggest using robocopy (http://www.microsoft.com/downloads/details.aspx?displaylang=en&familyid=9D467A69-57FF-4AE7-96EE-B18C4790CFFD)

Then use

robocopy c:\sourcefolder d:\targetfolder *.* /move /minage:143 /maxage:507
0
 

Author Comment

by:dalexan12456
ID: 17981984
sirbounty -

Let me see if I can find someone on the server team to download the server tool kit; I just tried the command from a command line in hopes that it might already been installed to no avail.  

If I wanted to do different date ranges, how would I do that?

Thanks!
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 17982065
I just placed your two date values in excel and subtracting them each from today...
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:dalexan12456
ID: 17983456
sirbounty -

When I tested this, I discovered that none of the expected files were moved; instead, all of the other files were moved!  I did some research and discovered that robocopy copies everything unless you add a switch to exclude files - so it didn't move anything from July 1, 2005 - June 30, 2006.  I tried again, but used the following instead -

robocopy c:\sourcefolder d:\targetfolder *.* /move /minage:20050630 /maxage:20060701

where minage is June 30, 2005 and maxage is July 1, 2006.  
Thanks for cluing me into robocopy!


0
 
LVL 67

Expert Comment

by:sirbounty
ID: 17983498
Ah - I've always used the calcuations for my purposes in this scenario.
Glad you got it working - robocopy is indeed a great admin tool...don't part with it! :^)
Thanx
0
 
LVL 4

Expert Comment

by:Meldrachaun
ID: 17984109
Here's a batch file that will do the trick - run in the directory you want to move the files from, and replace d:\mydir to the place you want to copy the files.  Copy and Paste the bat file, don't retype - some of the vars are case sensitive.

@echo off

if exist filelist1.txt del filelist1.txt
if exist filelist2.txt del filelist2.txt
if exist DoMove.bat del DoMove.bat

for %%I in (*.*) do @echo %%~tnxI >>filelist1.txt

findstr /R ^0[7-9]/[0-9][0-9]/2005 filelist1.txt >>filelist2.txt
findstr /R ^1[0-2]/[0-9][0-9]/2005 filelist1.txt >>filelist2.txt
findstr /R ^0[1-6]/[0-9][0-9]/2006 filelist1.txt >>filelist2.txt
for /F "tokens=4*" %%I in (filelist2.txt) do echo move /y "%%I %%J" d:\mydir\ >>DoMove.bat
call DoMove.bat
del filelist1.txt
del filelist2.txt
del DoMove.bat
0
 

Expert Comment

by:gpropp
ID: 26010931
Here is something even easier!
FORFILES -p "D:\Backup\" -s -m *.bak -d -8 -c "CMD /C del @path"

-d -8 ---files older than 8 days
*.bak --- file types / extension
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 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