Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Windows Script Searching for files by date

Posted on 2011-03-17
5
Medium Priority
?
484 Views
Last Modified: 2012-05-11
Hi all,

I'm coming up with a script to run on our file server that will find and move (as in copy to new location then delete the original) all files within a shared directory that were last accessed before 01/01/2009 (so anything 12/31/2008 or earlier would be moved.) We will then archive all the moved files offsite.

So far, my script will just be a simple batch file using the FORFILES command, as seen below. Please keep in mind I'm trying to teach myself batch scripting, so if I'm headed in the right direction, please don't give me everything I need in one fell swoop! (I still need to work on my /C argument, obviously.)

So to sum up my current question, the /D command will search by date last modified, but is there a way to search by date last accessed?

FORFILES /S /P C:\PATH_TO_BACKUP /D -12/31/2008 /C "cmd /c echo @file"

Thanks!
0
Comment
Question by:biofishfreak
[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
  • 2
  • 2
5 Comments
 
LVL 5

Accepted Solution

by:
rorybreen earned 500 total points
ID: 35160756
Hello,

I'm not sure if this is exactly what your after as it's a GUI...

http://www.nirsoft.net/utils/bulk_file_changer.html
0
 
LVL 9

Expert Comment

by:Murugesan Nagarajan
ID: 35163710
An example BATCH code:
echo off & setLocal EnableDELAYedExpansion
PUSHD Y:\DIR1\DIR2\
SET source=Y:\DIR1\SUBDIR1\
SET dest="F:\DIR1\SUBDIR1\"
for /f "tokens=* delims= " %%a in ('dir/s/b/ad') do (
pushd "%%a"
if not exist "!dest!%%a" md "!dest!%%a"
:: or: md "!dest!%%a" 2>nul
for /f "tokens=* delims= " %%b in ('dir/b/a-d') do (
set year=%%~Tb
:: ASSuming filedate looks like 01/02/2009
set year=!year:~6,4!
IF "!year!" NEQ "2010" >>F:\MOVE.bat ECHO MOVE /Y "!source!!FILE!" "!dest!%%a"
)
)
:: safetied off until verified
echo examine the batchfile...
more F:\move.bat

Open in new window


which is available at the following location:
http://www.computing.net/answers/programming/move-files-based-on-date-modified/20853.html

The mentioned url describes about XXCOPY  and other informations.
0
 
LVL 3

Author Comment

by:biofishfreak
ID: 35183377
Thanks for the prompt responses, but murugesandins, that script is still looking at the date modified meta data, and I need to look at the date last accessed.

Rorybreen, that software actually looks pretty promising... but I'd still prefer a script of some sort, but that might work.

I'm going to keep digging for the time being, and hope to come up with something. Also, I'm over the "learning" part of the script, and if someone finds a full script to accomplish what I want, I'll take it! :-)
0
 
LVL 5

Expert Comment

by:rorybreen
ID: 35190936
Maybe find a utility to make the modified date the same as the last accessed date, that may be an approach for you.
0
 
LVL 3

Author Closing Comment

by:biofishfreak
ID: 35191949
While not a script, the nirsoft bulk file changer does everything I need. Thanks for the prompt response!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This may not be a text book method to resolve VSS backup issues but it seemed to have worked on few of the Windows 2003 servers we had issues while performing a Volume Shadow Copy backup. If you have issues while performing a shadow copy backup usin…
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

618 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