我通过分析生成了一些图像文件。每次进行分析时,文件名都是相同的。我已经创建了一个演示文稿,并且我正在使用Libre Office Impress。 让我们说,我有三个图像image1.png,image2.png和image3.png,我应该把这些图像放在第3页,第5页和第8页
现在,我手动插入图片。我知道非常基本的shell脚本。所以我想知道什么是bash shell脚本自动创建一个libre office impress文件,图像自动插入上面提到的页面。
答案 0 :(得分:0)
如果.odp文件的主要部分没有更改,则可以使用 flat openDocument 格式制作模板,其中3个图像的名称由脚本更新。
平面文档是一个未压缩的 xml 文档,可以使用文本编辑器打开,手动更改某些部分谨慎。通常,此类文档的名称与.fodp
相同。您必须以平面格式保存此模板,并指向图像的链接而不是合并它们。
因此。 让我们说:
/path/to/the/template.fodp
image1.png
,第二张为image2.png
,第三张为image3.png
。/path/to/the/document
中,这将是最终文档。让我们编写一个脚本 insertImages.sh
myTpl="$1" # will contains '/path/to/the/template.fodp'
myDir="$2" # will contains '/path/to/the/document'
img1="$3" # will contains the name of the first image in myDir
img2="$4" # will contains the name of the second image in myDir
img3="$5" # will contains the name of the third image in myDir
[[ -f "$1" ]] && cp "$1" "$2/document.fodp" || exit 1 # checks if the template exists and copy it
[[ -f "$3" ]] && sed "$2/document.fodp" "s/img1.png/$3/" || exit 1 # overwrite the name of the first image
[[ -f "$4" ]] && sed "$2/document.fodp" "s/img2.png/$4/" || exit 1 # overwrite the name of the second image
[[ -f "$5" ]] && sed "$2/document.fodp" "s/img3.png/$5/" || exit 1 # overwrite the name of the third image
应该以这种方式调用此脚本:
insertImages.sh "/path/to/the/template.fodp" "/path/to/the/document" "image1.png" "image2.png" "image3.png"
我不是一个大程序员。所以这些线路可能存在一些错误。但原则就在那里。
他们是一些人: