#!/usr/bin/perl # moveContent # looks for zip files in relative directory ./etd_deposits # ( a softlink of /home/ftpaccess) # calls stat on them to get the date modified # takes those dates and turns them into a yyyymmdd format # creates those directories in /home/ftpaccess # moves the zip files into the directory that matches # their datestamp # for ETD preprocessing # jody DeRidder, 4/26/10 $base = "../etd_deposits/"; opendir(DEPO, $base) or die "can't read $base\n"; while ($file = readdir(DEPO)){ if ($file =~ /^\./){ next;} # no dot files elsif ($file =~ /\.zip/i){ # looking for zip files $path = $base.$file; @d=localtime ((stat($path))[9]); $datestamp = sprintf ("%4d%02d%02d", $d[5]+1900,$d[4]+1,$d[3]); $dirpath = $base.$datestamp; if (! -e $dirpath){ if ( `mkdir $dirpath`){ die "Error! could not create $dirpath\n";} } $newloc = $dirpath."/".$file; if (`mv $path $newloc`){ print "Error! could not move $path to $newloc\n";} } } close(DEPO);