Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Move files that fall within a date range

Posted on 2006-11-20
7
Medium Priority
?
6,209 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 2000 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
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 

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

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

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…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

971 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