Jump to content

Caitlin-havener

Members
  • Posts

    282
  • Joined

  • Last visited

Posts posted by Caitlin-havener

  1. Text file attached. Current code, below. Some files were renamed, others disappeared into the twilight zone.

    <?php$file=fopen("img/emvivacesupplemental2012/filelist.txt","r");$workingDir=getcwd();$directory= "\\img\\emvivacesupplemental2012\\450pxw\\";$newDirectory="\\img\\emvivacesupplemental2012\\gallery\\";$allFiles[][]= array();while (!feof($file)){$fileLine=trim(fgets($file));var_dump(scandir($workingDir.$directory));//echo $workingDir.$directory.$fileLine." is...<br/>";  //var_dump(file_exists($workingDir.$directory.$fileLine));  for($i=1000;$i<=9999;$i++)   {  //if first four characters  if ($i==substr($fileLine,0,4))  {   $allFiles[$i][]=$fileLine;   foreach ($allFiles as $v1) {    foreach ($v1 as $key => $v2) {	 rename($workingDir.$directory.$fileLine, $workingDir.$newDirectory.$i."_gallery_".$key.".jpg");    }   }  }  else if ($i==substr($fileLine,1,4))  {   $firstChar=substr($fileLine,0,1);   $allFiles[$firstChar.$i][]=$fileLine;   foreach ($allFiles as $v1) {    foreach ($v1 as $key => $v2) {	 rename($workingDir.$directory.$fileLine, $workingDir.$newDirectory.$firstChar.$i."_gallery_".$key.".jpg");    }   }  }  else if ($i==substr($fileLine,2,4))  {   $allFiles[$i][]=$fileLine;   foreach ($allFiles as $v1) {    foreach ($v1 as $key => $v2) {	 rename($workingDir.$directory.$fileLine, $workingDir.$newDirectory.$i."_gallery_".$key.".jpg");    }   }  }  else if ($i==substr($fileLine,3,4))  {   $firstChar=substr($fileLine,2,1);   $allFiles[$i][]=$fileLine;   foreach ($allFiles as $v1) {    foreach ($v1 as $key => $v2) {	 rename($workingDir.$directory.$fileLine, $workingDir.$newDirectory.$firstChar.$i."_gallery_".$key.".jpg");    }   }  }   }}//print_r($allFiles);fclose($file);?>

    filelist.txt

  2. Kay im still getting this error with and without the working directory specified: Warning: rename(C:\wamp\www\alluringassets\img\emvivacesupplemental2012\450pxw\8518_b.jpg,C:\wamp\www\alluringassets\img\emvivacesupplemental2012\gallery\8518_gallery_0.jpg) [function.rename]: The system cannot find the file specified. (code: 2) in C:\wamp\www\alluringassets\renamegalleryimgs.php on line 20

    while (!feof($file)){$fileLine=trim(fgets($file));   for($i=1000;$i<=9999;$i++)   {  //if first four characters  if ($i==substr($fileLine,0,4))  {   $allFiles[$i][]=$fileLine;   foreach ($allFiles as $v1) {    foreach ($v1 as $key => $v2) {	 rename($workingDir.$directory.$fileLine, $workingDir.$newDirectory.$i."_gallery_".$key.".jpg");    }   }  }

  3. It could be access issue. Try to verify all folders in the path:
    echo (int) file_exists('C:');echo (int) file_exists('C:\wamp');echo (int) file_exists('C:\wamp\www');echo (int) file_exists('C:\wamp\www\alluringassets');echo (int) file_exists('C:\wamp\www\alluringassets\img');echo (int) file_exists('C:\wamp\www\alluringassets\img\emvivacesupplemental2012');echo (int) file_exists('C:\wamp\www\alluringassets\img\emvivacesupplemental2012\450pxw');

    If all is OK, this should output "111111". The first folder where it goes to "0" is the problematic one. On that folder, you'll have to right click, select "Properties", and from the security tab, allow PHP to have access. One foolproof way is to give full access to "Everyone". This isn't a good idea if your computer is running a public facing site, but if it's just a development copy, that's OK.

    It's yielding all 1's!! Do I still need to change permissions??
  4. Forget those if statements for a moment. This is what I need to figure out. The following code is echoing does not exist for all the files. I need to first have them echoing that they do exist.

    $file=fopen("img/emvivacesupplemental2012/filelist.txt","r");$workingDir=getcwd(); $directory= "\\img\\emvivacesupplemental2012\\450pxw\\";$newDirectory="/img/emvivacesupplemental2012/gallery/";  $allFiles[][]= array(); while (!feof($file)){$fileLine=$workingDir.$directory.fgets($file);if (file_exists($fileLine)){  echo ($fileLine . "exists <br/>");}else{  echo ($fileLine. "does NOT exist </br>");}}?>

    Example of response: C:\wamp\www\alluringassets\img\emvivacesupplemental2012\450pxw\8518_b.jpg does NOT exist C:\wamp\www\alluringassets\img\emvivacesupplemental2012\450pxw\8518_f.jpg does NOT exist C:\wamp\www\alluringassets\img\emvivacesupplemental2012\450pxw\8551_b.jpg does NOT exist C:\wamp\www\alluringassets\img\emvivacesupplemental2012\450pxw\8551_f.jpg does NOT exist C:\wamp\www\alluringassets\img\emvivacesupplemental2012\450pxw\8653_b.jpg does NOT exist C:\wamp\www\alluringassets\img\emvivacesupplemental2012\450pxw\8653_f.jpg does NOT exist C:\wamp\www\alluringassets\img\emvivacesupplemental2012\450pxw\8654_b.jpg does NOT exist C:\wamp\www\alluringassets\img\emvivacesupplemental2012\450pxw\8654_f.jpg does NOT exist C:\wamp\www\alluringassets\img\emvivacesupplemental2012\450pxw\8655_b.jpg does NOT exist Those are the exact paths! I've also tried it without the working directory preceding it. Which would then read "\img\emvivacesupplemental\450pxw\8518_b.jpg does NOT exist!" I've also tried forward slashes instead of backslashes. All echo "does not exist".

  5. I'm working on wamp local server trying to rename some files with the following code:

    <?php$file=fopen("img/emvivacesupplemental2012/filelist.txt","r");$workingDir=getcwd(); $directory= "\\img\\emvivacesupplemental2012\\450pxw\\";$newDirectory="/img/emvivacesupplemental2012/gallery/";  $allFiles[][]= array(); while (!feof($file)){/*$fileLine=$workingDir.$directory.fgets($file);if (file_exists($fileLine)){  echo ($fileLine . "exists <br/>");}else{  echo ($fileLine. "does NOT exist </br>");}*/   for($i=1000;$i<=9999;$i++)   {  //if first four characters  if ($i==substr($fileLine,0,4))  {   $allFiles[$i][]=$fileLine;   foreach ($allFiles as $v1) {    foreach ($v1 as $key => $v2) {	 rename($directory.$fileLine, $newDirectory.$i."_gallery_".$key.".jpg");    }   }  }  else if ($i==substr($fileLine,1,4))  {   $firstChar=substr($fileLine,0,1);   $allFiles[$firstChar.$i][]=$fileLine;   foreach ($allFiles as $v1) {    foreach ($v1 as $key => $v2) {	 rename($directory.$fileLine, $newDirectory.$firstChar.$i."_gallery_".$key.".jpg");    }   }  }  else if ($i==substr($fileLine,2,4))  {   $allFiles[$i][]=$fileLine;   foreach ($allFiles as $v1) {    foreach ($v1 as $key => $v2) {	 rename($directory.$fileLine, $newDirectory.$i."_gallery_".$key.".jpg");    }   }  }  else if ($i==substr($fileLine,3,4))  {   $firstChar=substr($fileLine,2,1);   $allFiles[$i][]=$fileLine;   foreach ($allFiles as $v1) {    foreach ($v1 as $key => $v2) {	 rename($directory.$fileLine, $newDirectory.$firstChar.$i."_gallery_".$key.".jpg");    }   }  }   }}print_r($allFiles);fclose($file);?>

    I ran file_exists function on each line and nothing I do is yielding a boolean yes. I've tried preceding with the working directory, both forward and backslashes.. the images ARE in the right directory. Copied straight from properties of one of the images : C:\wamp\www\alluringassets\img\emvivacesupplemental2012\450pxw

×
×
  • Create New...