GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   PHP help needed. (https://gfy.com/showthread.php?t=925546)

Pics Traffic 09-03-2009 07:48 AM

PHP help needed.
 
I need to delete a bunch of files from subdirectories that have "pix" string in its name.

Is there way to do it with php script that I can run thru browser?
sort of like doing comand but with a siple script.

del /S *pix*

UniqueD 09-03-2009 07:56 AM

youre going to have to write a script that looks through the directories recursively and checks the file names for the string. Its def doable.

quantum-x 09-03-2009 08:03 AM

This will do the trick.

PHP Code:

<?
foreach(globr('/path/to/dirname/','*pix*') as $v) unlink($v);
function globr($sDir, $sPattern, $nFlags = NULL) { 
  $sDir = escapeshellcmd($sDir); 
  $aFiles = glob("$sDir/$sPattern", $nFlags); 
  foreach (glob("$sDir/*", GLOB_ONLYDIR) as $sSubDir) 
  { 
    $aSubFiles = globr($sSubDir, $sPattern, $nFlags); 
   $aFiles = array_merge($aFiles, $aSubFiles); 
  } 
  return $aFiles;  } 
?>


quantum-x 09-03-2009 08:03 AM

Quote:

Originally Posted by UniqueD (Post 16271533)
youre going to have to write a script that looks through the directories recursively and checks the file names for the string. Its def doable.

No shit sherlock :P

Pics Traffic 09-03-2009 08:25 AM

Quote:

Originally Posted by UniqueD (Post 16271533)
youre going to have to write a script that looks through the directories recursively and checks the file names for the string. Its def doable.


I wish I would have thought of that. :1orglaugh

Pics Traffic 09-03-2009 08:26 AM

Quote:

Originally Posted by quantum-x (Post 16271571)
This will do the trick.

PHP Code:

<?
foreach(globr('/path/to/dirname/','*pix*') as $v) unlink($v);
function globr($sDir, $sPattern, $nFlags = NULL) { 
  $sDir = escapeshellcmd($sDir); 
  $aFiles = glob("$sDir/$sPattern", $nFlags); 
  foreach (glob("$sDir/*", GLOB_ONLYDIR) as $sSubDir) 
  { 
    $aSubFiles = globr($sSubDir, $sPattern, $nFlags); 
   $aFiles = array_merge($aFiles, $aSubFiles); 
  } 
  return $aFiles;  } 
?>



thanks man.

UniqueD 09-03-2009 08:28 AM

why the fuck did you ask if there was a way to do it if you already knew there was then?

quantum-x 09-03-2009 08:30 AM

Quote:

Originally Posted by UniqueD (Post 16271804)
why the fuck did you ask if there was a way to do it if you already knew there was then?

Keep digging! :1orglaugh:1orglaugh

camperjohn64 09-03-2009 08:33 AM

Quote:

Originally Posted by UniqueD (Post 16271804)
why the fuck did you ask if there was a way to do it if you already knew there was then?

I am speachless...

woj 09-03-2009 08:39 AM

Quote:

Originally Posted by MOCKBA (Post 16271768)
I wish I would have thought of that. :1orglaugh

:thumbsup:1orglaugh

Pics Traffic 09-03-2009 09:45 AM

Quote:

Originally Posted by UniqueD (Post 16271804)
why the fuck did you ask if there was a way to do it if you already knew there was then?

Please turn off your internet connection.

gornyhuy 09-03-2009 09:47 AM

Quote:

Originally Posted by MOCKBA (Post 16272192)
Please turn off your internet connection.

Is there a way to turn off your internet connection?

Pics Traffic 09-03-2009 02:24 PM

Quote:

Originally Posted by quantum-x (Post 16271571)
This will do the trick.

PHP Code:

<?
foreach(globr('/path/to/dirname/','*pix*') as $v) unlink($v);
function globr($sDir, $sPattern, $nFlags = NULL) { 
  $sDir = escapeshellcmd($sDir); 
  $aFiles = glob("$sDir/$sPattern", $nFlags); 
  foreach (glob("$sDir/*", GLOB_ONLYDIR) as $sSubDir) 
  { 
    $aSubFiles = globr($sSubDir, $sPattern, $nFlags); 
   $aFiles = array_merge($aFiles, $aSubFiles); 
  } 
  return $aFiles;  } 
?>



worked well. thanks again


All times are GMT -7. The time now is 09:42 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc