Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 2555  / 2 Years ago, sat, november 5, 2022, 8:27:04

Suppose I want to associate PPT files to be opened with a bash script that converts it to PDF then opens it with the approperiate PDF editor. How do I do that?



Conversion will be done with uniconv as I learnt from another question



uniconv -f pdf presentation.odt


I believe I have to change "presentation.odt" with the filename that triggered this script


More From » bash

 Answers
4

Do you mean that the script will be called with (for example) presentation.odt as an argument? The argument is available as "$1" in the script (the double quotes are required if the file name contains characters like spaces which the shell would otherwise expand). You can construct the name of the PDF file by stripping away the .odt suffix: ${1%.odt}. Note that it's unoconv, not the unrelated uniconv.



#!/bin/sh
unoconv -f pdf "$1"
appropriate-pdf-editor "${1%.odt}.pdf"

[#43781] Saturday, November 5, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
admin

Total Points: 459
Total Questions: 112
Total Answers: 109

Location: Equatorial Guinea
Member since Sun, Feb 14, 2021
3 Years ago
;