Help - Search - Members - Calendar
Full Version: Mass copied file - Now how to mass delete?
Linuxhelp > Support > Technical Support
I had to use a quick PHP script to copy a file to multiple directories to make another program function properly... and I used this code to do it:

<pre><?php system("find * -type d|xargs -i cp --verbose file.ext {}/."); ?></pre>COMPLETE!

Now, I don't like it.. I really don't.. I have it in directories I don't want.. it sent it EVERYWHERE. Is there a way for me to write a similar script to go into each directory find the one 'file.ext' and remove it from every folder? Essentially reversing what this last one did?

Yep - But how good at PHP are you? If you're OK at it then write yourself a recusrive function using opendir/readdir and unlink. You can probably acheive the same result using bash though.

I'll post a PHP script to do it if I have time tonight - I have a few directory-traversing scripts at home.

This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2018 Invision Power Services, Inc.