Recursively read subdirectory, check names of subdirectories in mysql db, if not exist: delete directory
1 view
Skip to first unread message
DanH
unread,
Jul 2, 2009, 10:30:02 AM7/2/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Professional PHP Developers
Hello everybody :)
To finish my little project i would like to make a cleaner.php script.
I will call it via cron and want it to check 1 main directory for
subdirectories.
I only care about the 1st level subdirectories and their names. When i
delete a directory i want to delete the directory, all its
subdirectories (if there are any) and all its files.
Step 1:
Read in all the subdirectories from the main directory.
Step 2:
When the subdirectories in the main directory are known, i want to
check if these names are known in the database.
Step 3:
If they are known in the database; do nothing.
If they are not known in the database; delete the directories that are
not known in the database (and their subs/contents).
Can anyone help me with this please? Please give me some hints.
If any freelancers find this a nice script to code for a reasonable
price let me know too ;)
thanx!
Dan
Christopher Robinson
unread,
Jul 2, 2009, 11:17:22 AM7/2/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
Delete the directories with rmdir() (there are a number of folks who
have posted recursive directory removal scripts on this page ...that is
if you don't use the iterator class to build your own):
http://us.php.net/manual/en/function.rmdir.php
I assume you know how to check against the database.