Batch Convert JFIF Files to JPG on Linux (Without Losing the Originals)

Batch Convert JFIF Files to JPG on Linux (Without Losing the Originals)

You just got a folder full of .jfif images. Maybe they came from an old camera, a scanner, or some random export. You need them as regular .jpg files so WordPress, WooCommerce, or your image gallery can handle them without complaining.

This is a common small annoyance for anyone running a Linux server or managing a website. The good news is it only takes a couple of minutes once you know the right commands.

Why JFIF Exists and Why It Matters

JFIF is basically a JPEG file that uses a different extension. The image data inside is the same. Most programs open them fine, but some upload forms, CDN setups, or older plugins only accept .jpg or .jpeg.

So you need a clean batch conversion. The main decision is whether you want to keep the original files or not.

The Fastest Safe Method (Keeps Your Originals)

I always prefer the safe route first. Install ImageMagick if you don’t have it yet:

# Ubuntu/Debian
sudo apt install imagemagick

# Fedora
sudo dnf install ImageMagick

# Arch
sudo pacman -S imagemagick

Then run this in the folder that contains the .jfif files:

mkdir -p jpg_output
for f in *.jfif; do
  convert "$f" "jpg_output/${f%.jfif}.jpg"
done

This creates a new folder called jpg_output and puts the converted .jpg files inside it. Your original .jfif files stay untouched.

Why the loop? It handles file names with spaces and special characters properly. The ${f%.jfif} part simply strips the old extension.

If you want a specific quality level (for example 90):

convert "$f" -quality 90 "jpg_output/${f%.jfif}.jpg"

The One-Command Version That Deletes the Originals

A lot of people (including me the first time) try this:

mogrify -format jpg *.jfif

It works. It converts every .jfif file to .jpg.

But it also deletes the original .jfif files.

mogrify is designed for in-place changes. When you change the format, ImageMagick writes the new file and removes the old one. There is no “keep original” switch with this exact command.

If you are 100% sure you no longer need the .jfif versions, go ahead. Otherwise stick to the convert loop above.

Just Rename Them (Sometimes Enough)

Because the data inside is already JPEG, renaming often works:

for f in *.jfif; do
  mv -- "$f" "${f%.jfif}.jpg"
done

Or if you have the rename tool:

rename 's/\.jfif$/.jpg/i' *.jfif

I still prefer converting with ImageMagick when the files will be used on a live site. It re-writes the headers cleanly and lets you control quality.

Recursive Conversion (Subfolders Included)

If the files are scattered in folders:

find . -name "*.jfif" -exec sh -c 'convert "$0" "${0%.jfif}.jpg"' {} \;

This keeps the new .jpg files next to the originals. Add a quality flag if you want.

Quick Safety Tips

  • Always test on a small copy of the folder first.
  • If the images are already uploaded to a live WordPress site, download them, convert offline, then re-upload. Don’t run conversion commands directly on production media folders unless you have a solid backup.
  • Check permissions if you get “permission denied”. You may need sudo or to fix ownership with chown.

Quick Recap

  • Safe method that keeps originals: use the convert loop into a new folder.
  • Fast method that deletes originals: mogrify -format jpg *.jfif.
  • Sometimes renaming is enough.
  • Always test on a small batch first.

That’s it. One short terminal session and your .jfif headache is gone.

If you run into a permission error or quality loss, drop the exact command and error message in the comments and I’ll help you sort it out.

No Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.