0
I need to rename, randomly, all files with the extension . gif in a directory. I managed, using the following code:
$nome = substr(hash('md5',time()),0,10);
foreach (glob("*.gif") as $arquivo) {
rename($arquivo, $nome . basename($arquivo));
}
However, the file that had the name "exemplo1.gif" is now called "d8030d37e9exemplo1.gif", the next file "d8030d37e9exemplo2.gif"...
So the adjustments I’m having trouble making are:
- The new file name should not contain the original name
- The start of the new name is repeated for all renamed files ("d8030d37e9")
It worked exactly as I wanted, thank you!
– Wesley