Hi,

I want to know how can I rename the file name on my host but keep the same extension.

For example:

abcdefg.jpg to new_file.jpg
abcdefg.jpeg to new_file.jpeg

Thanks,
Jassim

    [man]pathinfo[/man] with the PATHINFO_EXTENSION constant will get you the extension from a file name (with or without complete pathing)

      Use regular expressions to cut particular substrings from the filename and access them.

        Unless you have special requirements concerning the "file extension", pathinfo is a better solution than regular expressions because it is more descriptive of what is happening (assuming you use the named constant), and the reader does not need to check the regex pattern.

          Write a Reply...