Skip to content
Advertisement

What is the best way to rename all the images in a folder in php?

I’m new in PHP and would like to know how I can rename all the pictures in a folder in PHP.

I have a folder that contains different pictures all named :

JavaScript

I would like to add a K in front of the name of each image and change the numbers 1,2,3,4,5… to a,b,c,d

In the end I should have :

JavaScript

How do I do it please? I tried with the rename function to add the K but for the part where the letters are replaced by numbers I don’t see how to do it.

JavaScript

Advertisement

Answer

There may be an easier way to do this but here is one way:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement