9 use File::Path qw(make_path);
11 my ($info_dir,$html_images) = @ARGV;
13 find(\&move_directories,$info_dir);
15 sub move_directories {
17 return unless $_ =~ /\.info(?:-\d+)?(?:\.gz)?$/;
18 open(my $info_fh,'-|','zcat','-f',$_);
20 while (defined ($l = <$info_fh>)) {
22 my @images = $l =~ /\[image\s+src="([^"]+)"/g;
23 for my $image (@images) {
24 my $image_dest = File::Spec->catfile($info_dir,
26 print STDERR "checking $image ";
27 my $image_no_lilypond = $image;
28 $image_no_lilypond =~ s{^lilypond/?}{};
29 my $image_dir = $image_no_lilypond;
30 $image_dir =~ s{/[^/]+$}{};
31 my $image_source = File::Spec->catfile($html_images,
33 $image_dir = File::Spec->catfile($info_dir,'lilypond',$image_dir);
34 if (-f $image_source and
37 print STDERR "moving to $image_dest\n";
38 if (not -d $image_dir) {
39 make_path($image_dir);
40 print STDERR "making $image_dir\n";
42 copy($image_source,$image_dest) or
43 die "Unable to move $image_source to $image_dest $!";
44 # we don't bother to stick a symlink here, because
45 # symlink_html_images_to_info_images will do that for
48 print STDERR "either $image_source doesn't exist or $image_dest exists\n";