[PHP] deleting directories
I have directory with huge number of directories (names by date artwork requested and client id number) with clients artwork. by accident, directory was opened by FrontPage and now in each directory is created _vti_cnf directory with copy of the artwork. i have to delete all those '_vti_cnf' directories. Since I don't have root access to server (shared hosting) I made a php script: $path = getcwd(); echo Current Directory: $pathhr; function list_directory($path) { if ($dir = opendir($path)) { while($file = readdir($dir)) { if($file != '.' and $file != '..') { echo b$file/b; if($file == '_vti_cnf') { rmdir($path./.$file); } else { if(is_dir($file)) list_directory($file); } } } } closedir($dir); } list_directory($path); But, it doesn't work. Im getting this Warnings: Warning: rmdir(20040301-040434-1411/_vti_cnf): Directory not empty in c:\ap\artwork\ap.php on line 19 Is there any other function that allows me to delete even not-empty directories? Or somebody has better idea? Thanks. Afan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] deleting directories
rm -r directoryname will recursively remove the directory and everything in it -Original Message- From: Afan Pasalic [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 21, 2004 12:31 PM To: php-general Subject: [PHP] deleting directories I have directory with huge number of directories (names by date artwork requested and client id number) with clients artwork. by accident, directory was opened by FrontPage and now in each directory is created _vti_cnf directory with copy of the artwork. i have to delete all those '_vti_cnf' directories. Since I don't have root access to server (shared hosting) I made a php script: $path = getcwd(); echo Current Directory: $pathhr; function list_directory($path) { if ($dir = opendir($path)) { while($file = readdir($dir)) { if($file != '.' and $file != '..') { echo b$file/b; if($file == '_vti_cnf') { rmdir($path./.$file); } else { if(is_dir($file)) list_directory($file); } } } } closedir($dir); } list_directory($path); But, it doesn't work. I'm getting this Warnings: Warning: rmdir(20040301-040434-1411/_vti_cnf): Directory not empty in c:\ap\artwork\ap.php on line 19 Is there any other function that allows me to delete even not-empty directories? Or somebody has better idea? Thanks. Afan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] deleting directories
Afan Pasalic wrote: I have directory with huge number of directories (names by date artwork requested and client id number) with clients artwork. by accident, directory was opened by FrontPage and now in each directory is created _vti_cnf directory with copy of the artwork. i have to delete all those '_vti_cnf' directories. Since I don't have root access to server (shared hosting) I made a php script: script snip But, it doesn't work. Im getting this Warnings: Warning: rmdir(20040301-040434-1411/_vti_cnf): Directory not empty in c:\ap\artwork\ap.php on line 19 Is there any other function that allows me to delete even not-empty directories? Or somebody has better idea? Thanks. Afan According to the documentation (http://us4.php.net/rmdir), the directory must be empty. You can use the Windows system command to delete a non-empty directory with either exec() or by using backticks. Sorry, but I don't remember what the Windows command is (del?). -- John C. Nichel berGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] deleting directories
Thanks Jesse, but I don't have an access to server. Just FTP. That's why I have to use php script. Jesse Castro wrote: rm -r directoryname will recursively remove the directory and everything in it -Original Message- From: Afan Pasalic [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 21, 2004 12:31 PM To: php-general Subject: [PHP] deleting directories I have directory with huge number of directories (names by date artwork requested and client id number) with clients artwork. by accident, directory was opened by FrontPage and now in each directory is created _vti_cnf directory with copy of the artwork. i have to delete all those '_vti_cnf' directories. Since I don't have root access to server (shared hosting) I made a php script: $path = getcwd(); echo Current Directory: $pathhr; function list_directory($path) { if ($dir = opendir($path)) { while($file = readdir($dir)) { if($file != '.' and $file != '..') { echo b$file/b; if($file == '_vti_cnf') { rmdir($path./.$file); } else { if(is_dir($file)) list_directory($file); } } } } closedir($dir); } list_directory($path); But, it doesn't work. I'm getting this Warnings: Warning: rmdir(20040301-040434-1411/_vti_cnf): Directory not empty in c:\ap\artwork\ap.php on line 19 Is there any other function that allows me to delete even not-empty directories? Or somebody has better idea? Thanks. Afan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] deleting directories
Jesse Castro wrote: rm -r directoryname will recursively remove the directory and everything in it snip He's on a Windows system, that won't work. As a side note, on *nix based systems, rm -rf dir would be better suited so that it doesn't prompt for conformation on each file/directory. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] deleting directories
directories are on Linux server and Windows System Commands will not work there. I forgot to make a note: warning shows c:\ap\artwork\ap.php because I test it locally, n windows machine. but directories are on Linux box sorry for misleading you guys. John Nichel wrote: Afan Pasalic wrote: I have directory with huge number of directories (names by date artwork requested and client id number) with clients artwork. by accident, directory was opened by FrontPage and now in each directory is created _vti_cnf directory with copy of the artwork. i have to delete all those '_vti_cnf' directories. Since I don't have root access to server (shared hosting) I made a php script: script snip But, it doesn't work. Im getting this Warnings: Warning: rmdir(20040301-040434-1411/_vti_cnf): Directory not empty in c:\ap\artwork\ap.php on line 19 Is there any other function that allows me to delete even not-empty directories? Or somebody has better idea? Thanks. Afan According to the documentation (http://us4.php.net/rmdir), the directory must be empty. You can use the Windows system command to delete a non-empty directory with either exec() or by using backticks. Sorry, but I don't remember what the Windows command is (del?). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] deleting directories
Afan Pasalic wrote: directories are on Linux server and Windows System Commands will not work there. I forgot to make a note: warning shows c:\ap\artwork\ap.php because I test it locally, n windows machine. but directories are on Linux box sorry for misleading you guys. Then that's a bit easier...for me. $command = rm -rf . $directory_name; exec ( $command ); -- John C. Nichel berGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] deleting directories
Sorry John, but I forgot to write that detail: I test locally on Win machine, but directories are on Linux server. Afan John Nichel wrote: Jesse Castro wrote: rm -r directoryname will recursively remove the directory and everything in it snip He's on a Windows system, that won't work. As a side note, on *nix based systems, rm -rf dir would be better suited so that it doesn't prompt for conformation on each file/directory. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] deleting directories
its pretty easy to make your function recursive, all you need to do is test if the current file is a directory (if (is_dir($file)){run function} else if (eregi('/_vti_cnf/',$file))), then delete all files as long as they are located in a _vti_cnf directory. And I'm sure I've done something wrong that won't please someone on the list, but hopefully this baic idea works and someone will be able to improve on it. On Tue, 21 Sep 2004 12:50:09 -0500, Afan Pasalic [EMAIL PROTECTED] wrote: Sorry John, but I forgot to write that detail: I test locally on Win machine, but directories are on Linux server. Afan John Nichel wrote: Jesse Castro wrote: rm -r directoryname will recursively remove the directory and everything in it snip He's on a Windows system, that won't work. As a side note, on *nix based systems, rm -rf dir would be better suited so that it doesn't prompt for conformation on each file/directory. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Jasper Howard - Database Administration ApexEleven.com 530 559 0107 --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Deleting directories...
Hi, I'm trying to delete non-empty directories. I'm using a windows 2000 server. I have a script that seems to be trying to delete the directories as it should but it can't delete the directories because it does not have permission. The script runs CHMOD on the direcory to make sure it has permission but it still doesn't work. Can anyone help? Thanks in advance - Philip Jeffs The Tickle Group The Gate House Summerseat Bury Lancashire BL9 5PE United Kingdom W: http://www.tickle.co.uk T: 01706 823456 F: 01706 829500 E: [EMAIL PROTECTED] (daytime) [EMAIL PROTECTED] (evening) -
Re: [PHP] Deleting directories...
On Tuesday 02 April 2002 16:42, Philip Jeffs wrote: Hi, I'm trying to delete non-empty directories. I'm using a windows 2000 server. I have a script that seems to be trying to delete the directories as it should but it can't delete the directories because it does not have permission. The script runs CHMOD on the direcory to make sure it has permission but it still doesn't work. Does the chmod operation actually work? Does the user which runs the webserver have permissions to chmod the directories that you want to delete? -- Jason Wong - Gremlins Associates - www.gremlins.com.hk /* May you live in uninteresting times. -- Chinese proverb */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php