Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> The shell script idea is neat.

Could be something as simple as:

  file_path="${1}"
  mime="$(file --mime-type --brief "${file_path}")"
  ext="${mime#image/}"
  mv "${file_path}" "${file_path%.*}.${ext}"
That does no checks (e.g. is the file an image) and may not work on something on something like a video, but it’ll do for common image types such as png, jpeg, webp, heic, gif…


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: