Skip to content

Instantly share code, notes, and snippets.

@tenox7
Last active July 9, 2023 09:36
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 tenox7/04361c115c723e9b3a0dba44215f0613 to your computer and use it in GitHub Desktop.
Save tenox7/04361c115c723e9b3a0dba44215f0613 to your computer and use it in GitHub Desktop.
universal convert shell script, name it as a destination extension, eg. 'jpg'
#!/bin/bash -e
src="${1?:No filename specified}"
dst="${src%.*}.$(basename ${0})"
echo "Converting '${src}' to '${dst}'"
[ -f "${src}" ] || { echo "Source file '${src}' not found"; exit 1; }
some_command "${src}" "${dst}"
[ -f "${dst}" ] || { echo "Destination file '${dst}' not found"; exit 1; }
rm -f "${src}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment