in reply to automated file move

Thanks to everyone for all the thoughtful replies, and taking time to sort out my somewhat lackluster description of the task. :) I tried several methods, including attempting to open the file for writing, but found what seems to be a fairly simple (and most reliable) solution using Perl's 'move' command. The following script can be run as is, provided the user sets the proper input/output directories and desired filetype. On my PC, this script runs with no noticeable effect on CPU usage. Any comments appreciated.
#!/usr/local/bin/perl use strict; use warnings; use File::Basename; # Gives us fileparse() use File::Path; # Gives us mkpath use File::Copy; # Gives us move ############################################################### # NOTE: Set these variables according to your paths and desired # filetype. # # Set input\output paths, filetype, and sleep time. my $inputd = 'C:\temp'; my $outputd = 'D:\test\output'; my $filetype = 'pcm'; my $sleeptime = 1; # seconds to wait between directory reads ############################################################### # Disable print buffer. $| = 1; # Print message to user. print "\nAutomated File Move Utility"; print "\n\nThis script is attempting to move all $filetype files:"; print "\nsource: $inputd\ndestination: $outputd"; print "\n\nPress Ctrl+C to stop...\n\n"; # Repeat indefinitely. while (1) { # Create output directory if it doesn't exist already. if (!-e $outputd) { mkpath ($outputd, 0) or die "\nError - unable to create $outputd: $!\n\n"; } # Get files (full path and name). my @infiles = glob ("$inputd\\*.$filetype"); # Form hash that relates input and output files. my %outfiles; foreach my $inputf (@infiles) { my $basename = fileparse ($inputf, $filetype); $outfiles{$inputf} = "$outputd\\$basename"."$filetype"; } # This block just provides feedback for testing purposes. if (0) { print "\nINPUT:"; foreach (@infiles) {print "\n$_"} print "\nOUTPUT:"; foreach (keys %outfiles) {print "\n$outfiles{$_}"} } # Wait for some time. sleep $sleeptime; # Attempt to move each input file. foreach my $inputf (@infiles) { next if (! move $inputf, $outfiles{$inputf}); print "\nMoved $inputf to $outfiles{$inputf}"; } }