ランダムな数字または文字でフォルダ内のすべてのファイルの名前を変更します。ランダムな名前のフォルダ内のすべてのファイルの名前を変更します。
この私のコード:
$dir = opendir('2009111');
$i = 1;
// loop through all the files in the directory
while (false !== ($file = readdir($dir))) {
// do the rename based on the current iteration
$newName = rand() . (pathinfo($file, PATHINFO_EXTENSION));
rename($file, $newName);
// increase for the next loop
$i++;
}
// close the directory handle
closedir($dir);
が、私はこのエラーを取得:
Warning: rename(4 (2).jpg,8243.jpg): The system cannot find the file specified
[XY問題](https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem)のように聞こえます。これで何を達成しようとしていますか?そして、あなたが得ているエラーは何ですか? – Chris
1. *このエラー*、何のエラー? 2.あなたの 'while()'ループに変数 '$ i'を使っている点はありません。 –
警告:rename(4(2).jpg、8243.jpg):指定されたファイルが見つかりませんでした。 – dexter