Delete folder with large number of files - ftp

I want to delete a folder with large number of files (>100.000).
I only have FTP access. No SSH.
Do you have any ideas how to run commands via Terminal to delete? It seems to be impossible to do it with Filezilla.

You may use one of these console based ftp-clients:
General Unix:
NcFTP
Debian /Redhat:
yafc
Windows:
Just use the built in cmd and type:
ftp -? //for available commands
delete remote__file_name //for file deletion
rmdir directory_name //for dir deletion

Related

WinSCP recursively find all files with certain extension and upload it to FTP server

I need to recursively find *.log files at C:\ and send them to my server using WinSCP. I've experimented with put but it can only send files from a given directory. After that I've tried using cmd's dir to get the list of required files and then send them using WinSCP, but I can't both open connection AND send files: cmd prompt changes to winscp> after I open connection from cmd.
I'd appreciate any help.
Use -filemask switch in put command to upload only files matching a mask:
put -filemask=*.log C:\ /remote/path/
If you want to avoid "uploading" folders that contain no *.log files:
put -filemask=*.log -rawtransfersettings ExcludeEmptyDirectories=1 C:\ /remote/path/

How to list the sub directories in a Windows FTP server?

I'm trying to list all the directories and sub directories in a windows server from Unix FTP command. I tried dir -r command but it only displays the directories in current folder. dir /s command is not displaying anything. I don't have utilities like winexe also. Any idea would greatly help me. Thanks in advance.
There's no command to list directories recursively in the common *nix ftp command-line client.
Some FTP servers (like ProFTPD) support switches to the LIST command (and similar). But that's a non-standard behavior that does not have any backing in the FTP specification/RFC.
You didn't specify what Windows FTP server you are using. Assuming IIS: The IIS does not support any switches at all, what is the correct behavior. It is a task for the client to do the recursion. But again, the common *nix ftp client does not support that.
Similar question:
Get a whole FTP directory listings recursively in one call possible to reduce time
Try dir -R. dir /s is a windows command, and dir -r is reversing the output order.

Automatically copy contents of FTP folder to local Windows folder without overwrite?

I need to copy all the files of an FTP folder to my local Windows folder, but without replacing the files that already exist. This would need to be a job/task that runs unattended every hour.
This is what the job would need to do:
1. Connect to FTP server.
2. In ftp, move to folder /var/MyFolder.
3. In local PC, move to c:\MyDestination.
4. Copy all files in /var/MyFolder that do not exist in c:\MyDestination.
5. Disconnect.
I had previously tried the following script using MGET * (that runs from a .bat), but it copies and overwrites everything. Which means that even if 1000 files were previously copied, it will copy them again.
open MyFtpServer.com
UserName
Password
lcd c:\MyDestination
cd /var/MyFolder
binary
mget *
Any help is appreciated.
Thanks.
Use wget for Windows.
If you want to include subdirectories (adjust the cut-dirs number according to the depth of your actual remote path):
cd /d C:\MyDestination
wget.exe --mirror -np -nH --cut-dirs=2 ftp://UserName:Password#MyFtpServer.com/var/MyFolder
If you don't want subdirectories:
cd /d C:\MyDestination
wget.exe -nc ftp://UserName:Password#MyFtpServer.com/var/MyFolder/*
The "magic" bit (for this second form) is the -nc option, which tells wget not to overwrite files that are already there locally. Do keep in mind that old files are also left alone, so if a file on your FTP server gets edited or updated, it won't get re-downloaded. If you want to also update files, use -N instead of -nc.
(Note that you can also type wget instead of wget.exe, I just included the extension to point out that these are Windows batch file commands)

DOS ftp listing to local file

I'm trying to find a way to see if a file exists on an ftp site via DOS. I tried a get command on the file hoping that if it didn't exist it wouldn't download it to my local directory. However it seams that it still does, but it's an empty file. This doesn't work for me however because the file I'm looking for is just a empty trigger file so I can't tell the difference.
I would like to dump a listing ls of the ftp directory to a text file on my local drive and so I try
ls > listing.txt.
It creates the listing.txt file locally but it's always empty even though there are files on the ftp site.
What are my options with this?
I have used dir > listing.txt and ls > listing.txt and every time listing.txt is empty even though there are files in the directories I'm running those commands on.
Sorry if I didn't make this clear, but I'm trying to get the listing for an automated process and not simply for my visual when manually doing this.
Unless you're on FreeDOS, you're probably not using DOS. Perhaps you're using ftp.exe in the windows console? If that's the case, don't use a normal file redirect. Instead check here the syntax for ls in the standard Windows ftp client:
ls [RemoteDirectory] [LocalFile]
So you can do a ls . listing.txt to get a list of files in the current remote directory. The listing.txt file will appear in your user directory, e.g. c:\Users\user.

how to copy whole directories using FTP commands

Anyone know how to put whole directories from local to another server using FTP command?
i had use mput , but it just transfer file only.
cd /images_temp --> ws_ftp virtual folder name
mput *.IMG --> just transfer multiple file
anyone can teach me what command i need to use to transfer whole directories?
thanks
You can use mput * or mget *. Confirm with a rather than y. You can change the prompting behavior using the prompt command. You will find more information in the manual page. In a unix environment, man ftp
You can iterate and decent into directories and use mput *.IMG but that would probably inefficient. Consider using ncftpput where you can upload the directory remotely with just one line.

Resources