Impossible to delete one folder

Chronos

Registered
Feb 22, 2005
1
0
151
I created for mistake a folder called test\\\aoi which is impossible to delete from the File Manager and from FTP.
I cannot rename or change anything on that folder so its impossible to do anything with it.
Is there a way to remove that folder from Cpanel?

Thanks for help

Chronos
 

Rick_E

Registered
Mar 5, 2005
1
0
151
The following PHP may delete your errant directory. Copy the following, substitute your misbehaving directory name, save it as a web page named deletedirectory.php, and upload to your web site. Then execute it by browsing to http://yourdomain.com/deletedirectory.php.

You may need to paste the following code into notepad first to strip out extra formatting. Then select all and copy the code back out and paste into your web page.

As always, it is good practice to back up your web site files first.


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
</head>

<body>
<?php
$directory='test\\\aoi';
removedir($directory);

function removedir($dir)
{
$dh=opendir($dir);
while ($file=readdir($dh))
{
if($file!="." && $file!="..")
{
$fullpath=$dir."/".$file;
if(!is_dir($fullpath))
{
unlink($fullpath);
}else{
removedir($fullpath);
}
}
}
closedir($dh);
if(rmdir($dir))
{
return true;
}else{
return false;
}
}

?>
</body>
</html>
 

K_aneda

Well-Known Member
Feb 29, 2004
56
0
156
Sydney, Australia
Could also try through FTP.
 

AndyReed

Well-Known Member
PartnerNOC
May 29, 2004
2,217
4
193
Minneapolis, MN
David is absolutely correct. SSH is the best method to delete a file/directory.
 

K_aneda

Well-Known Member
Feb 29, 2004
56
0
156
Sydney, Australia
Yeah, but also have to look @ alternatives if SSH is not available - not every host will help out.
However if SSH is disabled, could always lodge a support ticket to have it taken care of (that's if you don't own your own server)
 

dr2web

Active Member
Jan 14, 2005
33
0
156
If you can not do it from ftp or the file manager, as I see it the only options you would have is ssh, or the php code that was above, and quoted here...
Rick_E said:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
</head>

<body>
<?php
$directory='test\\\aoi';
removedir($directory);

function removedir($dir)
{
$dh=opendir($dir);
while ($file=readdir($dh))
{
if($file!="." && $file!="..")
{
$fullpath=$dir."/".$file;
if(!is_dir($fullpath))
{
unlink($fullpath);
}else{
removedir($fullpath);
}
}
}
closedir($dh);
if(rmdir($dir))
{
return true;
}else{
return false;
}
}

?>
</body>
</html>