I have a working script to generate thumbs to all pdf files in a folder( using Image Magic):
for f in *.pdf; do convert -thumbnail 250x200 "$f"[0]"_thumb_wd_${f%.pdf}.jpg"; done
How can i adjust this to check if the "_thumb_wd_+"f"+.jpg exists? So i can generate the thumbs only if it does not exists!
You can use
if
conditional construct to perform an action depending on some condition e.g. if something exists or not. In your case you need to put the action segment inside theif-then
condition:[[
is abash
keyword, we are using it to check (-f
) if the file_thumb_wd_${f%.pdf}.jpg
exists and is a regular file. The!
negates the operation, as a resultconvert
will only run if the file does not exist.So, your final script: