Solved

Move files that fall within a date range

Posted on 2006-11-20
7
5,271 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

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…
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

786 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