my $source = 'c:/win/data'; my $to_dir= 'c:/temp/DATA'; use File::Path; mkpath(${to_dir}) or die "mkdir '${to_dir}' failed: $!" if not -e $to_dir; open(FH,">${to_dir}/EXCLUDE.txt"); print FH ".lck\n"; close FH; my $xcopy = $ENV{'systemroot'} . '\\system32\\xcopy.exe'; my $exclude="${to_dir}/EXCLUDE.txt"; $exclude =~ s/\//\\/g; my $command = qq{("$xcopy" "$source" "$to_dir" /E /I /F /R /Y /EXCLUDE:$exclude)}; print $command . "\n"; system($command); unlink $exclude;