Created
March 16, 2022 02:11
-
-
Save AllanChain/dbfcebfcbb3ca5fe5c9bfa25fcd57c15 to your computer and use it in GitHub Desktop.
Script to convert ppt(x) to pdf using cloudconvert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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...") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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