Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to move all files in a directory not accessed in last hour.

Status
Not open for further replies.

auto

MIS
Aug 30, 1999
9
US
I am new to Perl and can list all files in a directory. But I am having problems using the Date::Calc module to list all files in a directory and move only the files that have not been accessed in over 1 hour. I am trying to do this on a NT Server. Any help or suggestion would be greatly appreciated.....Thanks
 
You could try using stat to get the file information.
The ninth element in the list is the modified time, and is in the number of seconds since the epoch.

If you take the localtime, convert to seconds, subtract the number of seconds (3600) and use this value to compare against the modified time.

$now = time();
$now-=3600;
if $mtime > $now {file accessed within 1 hour }

HTH ;P
 
Thank You PaulTEG your information solved my problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top