Solved

Move files that fall within a date range

Posted on 2006-11-20
7
5,647 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
[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
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
[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

 

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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
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…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
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…

729 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