On 02.07.2010 23:02, Jonah Lee Walker wrote:
So I want to either write an applescript to automate a search for
multiple files, or a search expression so that I can extract
everything between the<img src="  and " border=0>  in the document and
have them all pasted into another document, skipping everything else
in the document.

Any help would be greatly appreciated.




Hello all!


And here comes a perl solution:

the following script extracts all image tags starting from a folder certain folder ... much more interesting to code would be the following questions: print the images only once for each file; or: does these images are existing? or: which superfluous images are populating my image folder ...

If one of these questions are your intention Jonah Lee Walker, then let me know! If you have doubts, how to run a perl-script, let me know privately ...


#!/usr/bin/perl

# This script "extract_image_tags.pl" extracts all image tags off all pages.html of a given folder and writes it into the file "found_images.txt"

use warnings;
use strict;
use File::Find;

my $start_dir = "/Users/user/Documents/webpages/your_page";
# starting point of your web site folder
# please adapt to your needs!

my $images = "$start_dir/found_images.txt";

open OUT, ">$images" or die "$!";

unless ( -d $start_dir ) {
    die "Your start directory \"$start_dir\" is not a directory";
}

print OUT
"\n\nYour script found following images in your web site directory\n\t\"$start_dir\":\n\n";

find( \&process, $start_dir );

sub process {

    return unless /\.s?html?$/;

    #   print "\t$File::Find::name\n";
    my $file = $File::Find::name;
    unless ( open IN, $file ) {
        warn "can't open $file for reading: $!, continuing ...\n";
        return;
    }
    my $data = join '', <IN>;
    close IN;
    return unless $data;
    my @targets = ( $data =~ /<img [^>]+?>/gi );
print OUT "\n\nThe file \"$file\" contains following image tags:\n\n\t";
    print OUT join "\n\t", @targets;
}


--
You received this message because you are subscribed to the "BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem, please email "supp...@barebones.com" rather than posting to the group.

Reply via email to