Skip to content

Instantly share code, notes, and snippets.

@lysender
Created August 14, 2023 08:37
Show Gist options
  • Save lysender/634d650153763e76872f7b0a1a146bd5 to your computer and use it in GitHub Desktop.
Save lysender/634d650153763e76872f7b0a1a146bd5 to your computer and use it in GitHub Desktop.
Bulk rename files in linux

Rename all files in current directory and sub-directories in certain pattern

I have several photos compiled in directories. However, these photos were processed by some old application and don't have file name extensions.

I would just assume that they are all JPG files so I want to rename all files to have the .jpg extension.

Will use the find and exec combination.

First, let's test it with a safer echo command. The command simply echos for original filename and the desired filename.

find ./ -type f -name "*"  -exec echo "{}" "{}.jpg" \;

Once confirmed that it is working, let's rename them all.

find ./ -type f -name "*"  -exec mv "{}" "{}.jpg" \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment