Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FTP Delete non empty directory

Tags:

unix

ftp

I am connected to a Unix server and I am trying to, via FTP, delete the directory dir with several files in it. If I use

ftp> delete dir/* 

I get

550 Wildcard is ambiguous.

When I use

ftp> prompt off Interactive mode off. ftp> mdelete dir/* 

I still get

550 Wildcard is ambiguous.

When I try

ftp> glob Globbing on. ftp> mdelete dir 

I'm prompted for every file.

How can I easily delete/empty-and-delete a directory without getting prompted for every file?

like image 453
JonatanEkstedt Avatar asked May 25 '12 06:05

JonatanEkstedt


People also ask

How do I get rid of directories that aren't empty?

To remove a directory that is not empty, use the rm command with the -r option for recursive deletion. Be very careful with this command, because using the rm -r command will delete not only everything in the named directory, but also everything in its subdirectories.

Can you delete files with FTP?

You can use the FTP_DELETE and SFTP_DELETE objects to delete files from an FTP or SFTP server. You can delete all files from a folder, delete specific files from a folder, or delete specific files using the File_Path field. . You do not need to filter by the File_Path field when you create a mapping.

Can you remove delete a non empty directory using the command rmdir?

rmdir command – Delete directory only if it is empty. rm command – Remove directory and all files even if it is NOT empty by passing the -r to the rm to remove a directory that is not empty. In other words, remove non empty folder.


2 Answers

I got it to work in two steps, on a server with restricted access, no SFTP, only FTP through commandline.

Like this :

mdelete folder_name/* rmdir folder_name 
like image 64
EcchiOli Avatar answered Oct 14 '22 21:10

EcchiOli


If you've hidden files or folders on your server (for example .folder), you have to set the lftp list-options to "-a".

So this worked for me:

$ lftp -u user,pass server > set ftp:list-options -a > cd /folder/to/be/empty/ /folder/to/be/empty/> glob -a rm -r * 
like image 20
philsch Avatar answered Oct 14 '22 20:10

philsch