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?
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.
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.
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.
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
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 *
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With