Assume a set of .docx files are in a directory to be converted to .pdf format. Is there a clever way to list the files and pipe it into a command that would 'print' the pdf files to a target directory? For example the resulting output of
ls -l *.docx
would be fed into the pdf-command (how this is done is at your discretion).
Assume MS-Word is not installed on the PC (Office Libre installed).
Preference is for solutions requiring minimal installation of Ubuntu utilities / packages and are well documented. Thank you
This simple command should help:
Or:
The format is:
Where:
application without GUI. This special mode can be used
when the application is controlled by external clients
via the API.
Then to "output" the converted files I used this command:
Info:
ls -p
: Append indicators to folders.grep -v /
: Only return files.xargs -d "\n"
: Used to pass the output to thesoffice
command, takes care of white spaces in filenames.2> /dev/null
: Hide errors.grep -Eo "/.*\.doc[x]?"
: Return only affected files. And the[x]?
catches both.docx
and.doc
files as used on my end and can be left out.Let me add an anwser using the example OP gave:
see: https://ask.libreoffice.org/en/question/2641/convert-to-command-line-parameter/
User
soffice --help
to see more options to that command.unoconv was a fast and simple, though for some reason on the first try it returned an error.
Install:
Usage:
The command to converts all .docx documents in the current directory (whether two or a hundred) to pdf format and place them in the “proper_format” directory beneath the current directory. The directory "proper_format" is created if it does not exist.
For some reason the first attempt returned an error: