source: trunk/cic-hcap/bin/script/grab-images.pl@ 11852

Last change on this file since 11852 was 11852, checked in by mdewsnip, 18 years ago

Initial revision

  • Property svn:keywords set to Author Date Id Revision
File size: 1.6 KB
Line 
1BEGIN {
2 unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
3}
4
5
6use strict;
7use util;
8
9
10my $source_directory = "Z:\\";
11my $target_directory = "C:\\mdewsnip\\CIC\\Images.new\\";
12
13
14sub main
15{
16 # Find all the files in the source directory
17 if (!opendir(DIR, $source_directory)) {
18 die "Error: Couldn't read directory $source_directory\n";
19 }
20 my @directory_files = readdir(DIR);
21 closedir(DIR);
22
23 foreach my $directory_file (@directory_files) {
24 next if ($directory_file eq "." || $directory_file eq "..");
25
26 my $directory_file_path = &util::filename_cat($source_directory, $directory_file);
27 print "$directory_file_path ";
28 if (-f $directory_file_path) {
29 print "(File)\n";
30 }
31 else {
32 print "(Directory)\n";
33 my $images_revised_directory = &util::filename_cat($directory_file_path, "images REVISED");
34 if (-e $images_revised_directory) {
35 &copy_directory_to_local_drive($images_revised_directory);
36 }
37 }
38 }
39}
40
41
42sub copy_directory_to_local_drive
43{
44 my ($directory_file_path) = (@_);
45
46 my $destination_file_path = $directory_file_path;
47 my $source_directory_regexp = $source_directory;
48 $source_directory_regexp =~ s/\\/\\\\/g;
49 $destination_file_path =~ s/^$source_directory_regexp/$target_directory/;
50 print " Destination: $destination_file_path\n";
51
52 my $destination_directory_path = $destination_file_path;
53 $destination_directory_path =~ s/[^\\]+$//;
54 if (!-e $destination_directory_path) {
55 &util::mk_all_dir($destination_directory_path);
56 }
57
58 &util::cp_r($directory_file_path, $destination_directory_path);
59}
60
61
62main(@ARGV);
Note: See TracBrowser for help on using the repository browser.