Jump to content

Caitlin-havener

Members
  • Posts

    282
  • Joined

  • Last visited

About Caitlin-havener

  • Birthday 09/04/1988

Previous Fields

  • Languages
    html, css, javascript

Contact Methods

  • Website URL
    http://
  • ICQ
    0

Profile Information

  • Gender
    Male
  • Location
    Orlando, FL
  • Interests
    Web programming, graphic design

Caitlin-havener's Achievements

Member

Member (2/7)

3

Reputation

  1. Hey there! I'm trying to read in a csv and split the data at commas unless the string is encapsulated between double quotes. How would I do this? I know the function, its just the regular expression that confuses me!
  2. 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
  3. I've already made the gallery folder... next... lol. Still errors mehh
  4. 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"); } } }
  5. Someone else helped me on facebook. I actually had to use trim function ! Will let you know if I have trouble with this next part shortly
  6. It's yielding all 1's!! Do I still need to change permissions??
  7. 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".
  8. 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...