Skip to content

Instantly share code, notes, and snippets.

@AllanChain
Created March 16, 2022 02:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AllanChain/dbfcebfcbb3ca5fe5c9bfa25fcd57c15 to your computer and use it in GitHub Desktop.
Save AllanChain/dbfcebfcbb3ca5fe5c9bfa25fcd57c15 to your computer and use it in GitHub Desktop.
Script to convert ppt(x) to pdf using cloudconvert
#!/bin/python3
from os import environ
from pathlib import Path
from subprocess import call
from sys import argv
API_KEY = """
""".replace(
"\n", ""
)
def main():
print(Path(".").absolute())
if len(argv) == 1:
return
ppt_files = []
for file_name in argv[1:]:
file_path = Path(file_name)
if file_path.suffix.startswith(".ppt"):
ppt_files.append(file_name)
if len(ppt_files) == 0:
return
call(
["cloudconvert", "convert", "-f", "pdf", *ppt_files],
env={"CLOUDCONVERT_API_KEY": API_KEY, "PATH": environ["PATH"]},
)
if __name__ == "__main__":
try:
main()
except:
from traceback import print_exc
print_exc()
input("Press Enter to continue...")
#!/usr/bin/env xdg-open
[Desktop Entry]
Name=PPT2PDF Convert
Exec=pdf-cloud-convert %U
Icon=ms-powerpoint
Type=Application
Categories=Qt;FileTools;Office;
GenericName=Office
Terminal=true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment