#!/usr/bin/perl use strict; use warnings; use File::Copy (); use File::Spec; my $volume = ''; # empty string for Unix my @dirs = ( File::Spec->rootdir, 'Volumes', 'case-sensitive', 'projects', 'monks', '1190936' ); my $base = File::Spec->catpath( $volume, File::Spec->catdir( @dirs ), '' ); my @time = (localtime)[ 5, 4, 3 ]; $time[0] += 1900; $time[1]++; $time[1] = sprintf '%02d', $time[1]; $time[2] = sprintf '%02d', $time[2]; my $dir_for_today = File::Spec->catdir( $base, @time ); die "destination $dir_for_today is not a directory!\n" unless -d $dir_for_today; foreach my $file ( glob File::Spec->catfile( $base, '*.txt' ) ) { File::Copy::move $file, $dir_for_today or warn "Can't move $file to $dir_for_today : $!"; }