JREAM Posted June 9, 2009 Share Posted June 9, 2009 This is working good, but i got it doing this, 1st file duplicate: file_0.txt 2nd file duplicate: file_0_1.txt I wanted it to just change the #, file_0 to file_1, not add the additional _0_1_2 etc.. $var = 0; for ($i = 0; $i < 1; $i++) { if (file_exists($upload_path . $filename)) { // Split Extension $split = split('[/\\.]', $filename); // Grab Pieces $f_name = $split[0]; $f_ext = substr($filename, strrpos($filename, '.') + 1); $filename = $f_name ."_$var.". $f_ext; $var++; $i--; } } Quote Link to comment https://forums.phpfreaks.com/topic/161565-solved-file-renaming-kinda-easy-but-im-stuck/ Share on other sites More sharing options...
gevans Posted June 9, 2009 Share Posted June 9, 2009 change $filename = $f_name ."_$var.". $f_ext; to $filname_array = explode("_", $f_name); $filename = $filename_array[0] ."_$var.". $f_ext; Quote Link to comment https://forums.phpfreaks.com/topic/161565-solved-file-renaming-kinda-easy-but-im-stuck/#findComment-852582 Share on other sites More sharing options...
waynew Posted June 9, 2009 Share Posted June 9, 2009 Replied to wrong topic. Quote Link to comment https://forums.phpfreaks.com/topic/161565-solved-file-renaming-kinda-easy-but-im-stuck/#findComment-852604 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.