PHP's rename function doesn't work.
Save As Usefile5_for_rename.php
$filepath = "c:/users/administrator/desktop/new Folder/";
$readarray =file ($filepath. " Sub-set synopsis. txt ");
$sign 1 = "First";
$sign 2 = "Set";
$nameArray =array ();
if (! $readarray) {
echo "Failed to read the file with the filename function
";
}
Else
foreach ($readarray as $value) {
if (Strstr ($value, $sign 1) &&strstr ($value, $sign 2))
Use Strpos to pay attention to the byte bits of Chinese characters
Array_push ($nameArray, $value);
else echo "not found";
}
echo sizeof ($nameArray). "
";
To rename a file by order
$i = 1;
foreach ($nameArray as $value) {
$value =trim ($value); It is necessary
echo $value. "
";
$filename = $filepath. " (". $i.") ".". TXT ";
$value = $filepath. $value. ". TXT ";
Rename ($filename, $value);
$i + +;
if ($i >10) break; Total number of files in folder
}
Renaming files by mapping
echo "";
?>
-------------------------------------------------------Running results:
86
The 1th episode compete the demon by mistake.
Warning:rename ((1). txt, 1th episode compete the demon. txt) [Function.rename]: No error in R:\Program files\appserv\www\filetest\usefile5 _for_rename.php on line 30
2nd Ji Shi Jie cun qi Juyi
Warning:rename ((2). txt, 2nd Ji Jie cun qixing juyi. txt) [Function.rename]: No error in R:\Program files\appserv\www\filetest\usefile5 _for_rename.php on line 30
3rd episode nine Dragon Private Walk Yan ' an mansion
Warning:rename ((3). txt, 3rd episode nine Dragon Private Walk Yanan House) [Function.rename]: No error in R:\Program files\appserv\www\filetest\ usefile5_for_rename.php on line 30
The 4th episode of the Kintring of the boxing and righteousness help
Warning:rename ((4). txt, 4th ji Kintring) [function.rename]: No error in R:\Program files\appserv\www\filetest\ usefile5_for_rename.php on line 30
5th episode Boxing Town Kansai
Warning:rename ((5). txt, 5th episode boxing Town Kansai. txt) [Function.rename]: No error in R:\Program files\appserv\www\filetest\usefile5_ for_rename.php on line 30
6th episode Tangolunda Tonsure Temple
Warning:rename ((6). txt, 6th episode Tangolunda tonsure Temple. txt) [Function.rename]: No error in R:\Program files\appserv\www\filetest\usefile5 _for_rename.php on line 30
The 7th episode of Leopard head mistakenly into the white Tiger Hall
Warning:rename ((7). TXT, 7th episode of Leopard head mistakenly into the White Tiger Hall. txt) [Function.rename]: No error in R:\Program files\appserv\www\filetest\ usefile5_for_rename.php on line 30
8th Episode Inverted Chuiyangliu
Warning:rename ((8). txt, 8th episode inverted Chuiyangliu. txt) [Function.rename]: No error in R:\Program files\appserv\www\filetest\usefile5_ for_rename.php on line 30
9th episode Big Wild Boar Forest
Warning:rename ((9). txt, 9th episode of Wild Boar Forest. txt) [Function.rename]: No error in R:\Program files\appserv\www\filetest\usefile5_ for_rename.php on line 30
The 10th episode of Lin baseball coach
Warning:rename ((). txt, 10th episode Lin Stick flood coach. txt) [Function.rename]: No error in R:\Program files\appserv\www\filetest\ usefile5_for_rename.php on line 30
----------------------------
/*
Because the current path is a usefile5_for_rename.php file path, and I want to modify the 10 files in the $filepath directory:
------Solution--------------------
This seems to be a php5.3 bug, has not been corrected yet?
------Solution--------------------
is not required permission, not set to. It's not clear, is that upstairs?
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.