Ubuntu – Extract images from several doc files

14.04files

I have a folder with several doc files which contain a few images each of them. I want to extract those images from the docs:

unzip foo.docx "word/media/*"

The above command can extract the images from one file, but how can I apply this command to every file in a folder without typing one by one?

Best Answer

A simple loop will do the trick. unzip supports specifying a target directory, so you can do

for f in *.docx
do
    mkdir -p "$f"-images
    unzip "$f" "word/media/*" -d "$f"-images
done