Free web development scripts for the webmasterDevelopment Scripts

 Site Navigation
 o Development Scripts
 o Text Only Edition
 o PHP.net News
 o Tutorials
 o Register an account
 o New entries this week
 o Affiliates/Links
 o Contact Us
 o About us
 o Advanced Search

 Browse Path
 o 2 users online
 o Most users online: 67
 o Home
  o Perl
   o Files
    o Script

 Member Login
User Name
Password

 Standards
Valid XHTML 1.0!
Valid 
CSS!

 Recommended Links
 o PHP Freaks
 o Designer Baby Clothes
 o Advertise Here Make Money
 o Wedding Vendor Directory
 o devnet
 o Free Wedding Websites
 o OxyScripts
 o Open Source Design
 o designplace

file copier (Rated 5)

Description:

I knocked this up for a newbie on DS, who needed to move files over from one dir to another, but only if they were under 5 mins old (i.e. last touch)

Code starts here


#!/usr/bin/perl
use strict;
use File::Copy;

my $age;
my $destination="/home/chris/tmp/";
my $sourcedir="/home/chris/bin/";

my @files=`cd $sourcedir && ls`;

# iterate and copy each one
foreach (@files){
chomp;
# get the age in seconds
$age = (time() - (stat($sourcedir.$_))[9]);
print "\n$sourcedir.$_ is is $age seconds old\n";
if($age<300){
copy("$sourcedir$_","$destination$_");
}
}


Submitted by christo on 11-06-2003 15:23


Rate This Script

User Contributed Comments

Registered Members login
© Copyright 2003 - Devscripts.net