Batch File Renaming in WordPress

In the previous article, I talked about filename patterns. And if you are still with me, probably you decided to rename files before uploading them to media library. Great! Let’s see what tools we can use to make this process fast and painless.

Basically, there are two ways of batch file renaming in a context of WordPress. You can either rename files on your computer using different software or let WordPress do that job for you with the help of plugins.

Software Approach

There are quite a lot applications for batch file renaming. Some of them are:

They vary in renaming methods, number of features, and price. It doesn’t really matter which one you choose unless it can rename multiple files according to our pattern. I’ll show the routine using Renamer for Mac.

At the moment of writing, I use this application. But before I switched to Mac, I used NovA FileRenamer on PC.

Step 1. Organize Files

First of all we need to put all images for a post in a separate folder with a post name. If we stick to the example from the previous article, the name of the folder will be “three-ways-of-warming-up”. All files will go in there.

Batch File Renaming in WordPress

In case we have a gallery for each warming-up method, it is better to create three more folders inside, like so:

Batch File Renaming in WordPress

Step 2. Import Files to Renamer

After images are organized, we can open Renamer and import them. To do that you need to click the [+] sign in the left bottom corner of the screen and choose the folder with images.

Batch File Renaming in WordPress

Step 3. Set up renaming pattern

When images are imported to Renamer you need to choose Numbers action from the actions menu.

Batch File Renaming in WordPress

When done, set up the action to match our pattern.

  1. Set numbering to 01, 02, 03, 04
  2. Start number to 01
  3. Step value to 1
  4. Enter the post name to Attach text and add a dash (-) in the end
  5. Choose Text-number from Format
  6. Uncheck Continue numbering

Batch File Renaming in WordPress

And you are all set. Click Apply and all files will be renamed.

In the case of several galleries, you might want to rename each subfolder separately, altering the Attach text option each time.

Plugin approach

Alternatively, you can rename files during upload or after they are uploaded to WordPress. There are several plugins for this task.

File Renaming on upload

This plugin renames files during the upload process. It can remove all special characters and accents and convert all letters to lowercase.

It has several cool features, like adding date or site URL to a filename, but we are mostly interested in renaming based on the post title.

Here is the screenshot of the plugin settings page set up to match our filename pattern.

Batch File Renaming in WordPress

However, there are few issues with this plugin. If you upload multiple images at once, the image order number is attached to the filename without a preceding dash and zero. This plugin also doesn’t attach a number to a first image. This means that you get:

three-ways-of-warming-up.jpg
three-ways-of-warming-up1.jpg
three-ways-of-warming-up2.jpg

instead of:

three-ways-of-warming-up-01.jpg
three-ways-of-warming-up-02.jpg
three-ways-of-warming-up-03.jpg

There is also no way to rename files based on the post title and gallery title on the fly.

Not exactly what we are trying to achieve. Also, in order for images to be renamed, the post has to be already published. This means that if you click “Add New” post, enter the title, fill in some text, and add some images before hitting “Publish”, those images won’t be renamed. Their original filenames will be preserved.

There is a workaround for that. You can schedule publishing for, let’s say, next year, upload your images, finish editing and then actually publish the post. Not very handy.

Another issue would be non-English post titles. I tried it with Russian, and it didn’t go very well. Uploaded image showed up as broken in the dashboard and the new filename looked something like this:

%d0%b1%d1%80%d1%83%d0%ba%d0%bb%d0%b8%d0%bd%d1%81%d0%ba%d0%b8%d0%b9-%d0%bc%d0%be%d1%81%d1%82.jpg

Which is totally understandable, all non-URL-safe characters were encoded to URL-safe ones. Luckily this can be fixed too with the help of plugins that transliterate post slugs to English, e.g. Cyr-To-Lat. In order to make the whole thing work with this plugin installed, you need to save the post (or schedule it), so the slug is transliterated into English and saved to the database. And only then upload your images. This way they will be renamed.

Media File Renamer

Another cool plugin is Media File Renamer by Jordy Meow. By the way, he has many awesome plugins, which we’ll talk about in this series of articles.

Although, Media File Renamer is not a perfect tool for our task, it is totally worth mentioning.

It can rename files according to their titles (not post title but image title) once they are uploaded. This may be very handy if you don’t have too many images.

Conclusion

As you can see, what approach to choose depends mostly on number of images you upload on post basis. If there is only one image per post, plugins like File Renaming on upload or Media File Renamer will totally do the job.

If on the on the other hand you are uploading many images, it might be more convenient  to use software like Renamer.

Table of contents

Want some more tips on image management in WordPress. Here is the list of articles that will help you do it faster and less painful. Subscribe to my Twitter for more posts on WordPress.

  1. Better Image Workflow in WordPress
  2. What Image Size is Best for a Website
  3. Tips For Better Filenames in WordPress
  4. Batch Rename Files in WordPress
  5. Autofill Attachment Metadata in WordPress
Heads up! This is an archived website I decided to keep for history. Head on to a new one →