Jump to content

[SOLVED] file renaming, kinda easy but im stuck


JREAM

Recommended Posts

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--;
	}

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.