3

swftools are a unique set of tools but lack some user friendliness. They can't even iterate over provided objects:

Only one file allowed. You supplied at least two.

$ swfextract file.swf -i 1,2
warning! You should use the -P when extracting multiple objects

$ ls
file.swf  output.swf

$ swfextract file.swf -i 1,2 -P

$ ls
file.swf  output.swf
int_ua
  • 8,394
  • 12
  • 78
  • 144

2 Answers2

3

Use this one-liner

swfextract --outputformat "extract_%06d.%s" -a 1- file.swf

If you want to extract to a dir content, make that dir first:

mkdir content
swfextract --outputformat "content/extract_%06d.%s" -a 1- file.swf

Works fine.

See the docs.

Janghou
  • 5,499
  • 6
  • 43
  • 59
1

Here is a bash script to automate it:

#!/bin/bash
find_ext=".swf"
out_ext=".jpg"

[ "$1" == "" ] && echo "Add type arguments from swfextract: -j -p -f -F -m -i" && exit 1 

for arg in $@; do
    for file in `find . -name "*$find_ext"`; do 
    ids="`swfextract $file | grep "\[$arg\]" | sed 's#^.*ID(s) ##g' |  sed 's#, # #g'`"
        for id in $ids; do
            swfextract "$file" $arg $id -o "${file}_${id}${out_ext}"
        done
    done
done

Don't forget to check the *_ext variables. Feel free to improve the script by adding extensions automatically.

int_ua
  • 8,394
  • 12
  • 78
  • 144
  • I know this is very old, but I have a number of swf files each with a number of photos in them. I'm barely bash competent, so your code above is greek to me. I just created a bash script and put it in the folder with the swf files and when I run it is just spits out: Add type arguments from swfextract: -j -p -f -F -m -i A. Will the script above run through each swf and export each JPG? B. What am I doing wrong? I don't understand what "Add type arguments from swfextract" means or where to add them even if I did. – CRAIG Jul 05 '17 at 17:59
  • C. Also don't understand what you mean by "Don't forget to check the *_ext variables? – CRAIG Jul 05 '17 at 17:59
  • Try running this script with `-j` as the first argument, it's needed for catching IDs of objects (used in the line with `grep`). This way it should extract all JPEGs, meaning of other options should be on http://www.swftools.org/swfextract.html Maybe `-p` will work too and I'm not sure about others. – int_ua Jul 06 '17 at 17:16
  • Thanks so much for answering! Greatness! I am not following how I add in arguments? Like this? find_ext=".swf" out_ext=".jpg" $arg = "-P" – CRAIG Jul 06 '17 at 17:18
  • No, not in the script itself, when launching it, add the argument after its' name, something like this: `./bulk_swfextract.sh -j` where `bulk_swfextract.sh` is the filename of the script. – int_ua Jul 06 '17 at 17:35
  • 1
    Ahhhh. Totally got it. The combo of -p and -j extracted a ton of jpgs from a ton of swf files. Thanks so much!!!! – CRAIG Jul 06 '17 at 17:38