Deleting stubborn files from your host server
Have you ever had the situation where you wanted to delete a file or an entire directory structure from your host server and no matter what you tried it just wouldn’t go the way of the Dodo? I’ve had this problem more often than I think is fair, and I have just discovered a method which is far easier than the method I have been using in the past to get rid of them.
The problem tends to happen when files and directories are created by a script on your host server, rather than being uploaded. Some, not all, scripts create files and directories that actually own the files, therefore you don’t, and it can be a bit of a mission to convince the files that you are allowed to change their permissions so you can delete them.
I generally use a tool called Bharat's Cleanup Script which was written to enable a webmaster to change the permissions of files and directories.
From the site…….. any files it creates are owned by the webserver process. If you want to modify those files yourself, you need to get the webserver to change the permissions on them so that you have access. That's what this script is for.Download this file, unzip it and put it on your webserver as cleanup.php
Open it in your browser, and enter the path to your albums directory and this script will make every file in that path (that it can access) writable by everybody.
After that, you should be able to delete the files manually via your FTP client or via the shell.
This technique has served me well in the past but today I found that the Legacy File Manager within my hosts cPanel deleted an entire directory structure that was suffering from these ownership issues. As easy as 123! I selected the directory, deleted it and emptied the trash. No problem at all. Though using the cPanels File Manager or FTP software wouldn’t even think about deleting the offending files. Hopefully it wasn’t just a fluke and the next time I have the file permissions problem I’ll be able to use this fast and easy technique effectively.
