viewtopic.php?p=653310#p653310
https://github.com/TimothySimon123/file-converter
Commands
TL; DR
Code: Select all
find . -maxdepth 1 -iname '*.pdf' | xargs -I{} pdftoppm {} -jpeg {}
Code: Select all
sudo apt install poppler-utils
If you don't understand the above, here is the newbie-friendly version:
When you're within the folder containing all PDFs, Right click on the empty space, open terminal here, then type (or Right click -> Paste) this command , followed by an Enter :
Code: Select all
echo "Please wait. Converting......... Do NOT close this terminal" ; find . -maxdepth 1 -iname '*.pdf' | xargs -I{} pdftoppm {} -jpeg {} ; echo "Finished conversion. Please close this Terminal"
To convert just the first page of each pdf (Ignores all other pages)
Code: Select all
echo "Please wait. Converting......... Do NOT close this terminal" ; find . -maxdepth 1 -iname '*.pdf' | xargs -I{} pdftoppm -singlefile {} -jpeg {} ; echo "Finished conversion. Please close this Terminal"
This is forked off from viewtopic.php?p=652929#p652929 .
My original reply was viewtopic.php?p=652987#p652987 .
--- @ Huckleberry FinnHuckleberry Finn wrote: Thu Sep 16, 2021 12:15 pm This one is really handy , simple, requiring no extra software .. perfect indeed.
I'm also surprised how there's nothing easy to "batch" convert ..
So, maybe you put this in tips & tricks..
................
This command just applies this ( pdftoppm -jpeg ) for all PDF files in that folder (with find piping to pdftoppm via xargs)
More generally, we can use
Code: Select all
find <something_to_find> | xargs -I{} some_command {}
xargs will replace {} with the paths of matching files (supplied from find's stdout to xarg's stdin)
Even more generally, this is just using xargs -I{}
find -iname means that the match is case-insensitive (matches .PDF , .pdf , .Pdf , .PdF etc.,)
xargs -I{} means to replace all occurences of {} with the current line from stdin (and repeat the command for each line)
Ref: $ man xargs , $ man find
EDIT 1: I learnt from man xargs that -i is deprecated. Edited command to use -I{}
I added the echo's as a "newbie guard" to stop people from closing the terminal thinking the job is over (some people don't know when a command finishes its job), and this command may take a lot of time
Only a very minor drawback -- the output names are something like this: MyFile.pdf.jpg-1.jpg
EDIT: @Huckleberry Finn fixed that.
EDIT 2: Learnt that there is a similar way on another forum.Amigo wrote: Thu Sep 16, 2021 2:08 pm https://askubuntu.com/questions/1162790 ... pm-in-ubun
find . -maxdepth 1 -type f -name '*.pdf' -exec pdftoppm -jpeg {} {} \;
Done, you will find the new converted jpg files in the same directory alongside the old pdf files.
EDIT 3: Incorporated good things from that (-maxdepth 1 -type f)
EDIT 4: Incorporated good things from commands given by @Amigo and @Huckleberry FinnHuckleberry Finn wrote: Fri Sep 17, 2021 10:13 am So, @TimothySimon : My humble suggestion for next "dot release" :D is:
Replace the main command with @Amigo 's
(And) While you're at it: 2 Options:
"Convert All Pages"
"Convert just First Pages" (of each file)
One with
ls *.pdf | sed 's|\.pdf||' | xargs -I{} pdftoppm {}.pdf -jpeg {}
The other
ls *.pdf | sed 's|\.pdf||' | xargs -I{} pdftoppm -singlefile {}.pdf -jpeg {}