Empty folders on FTP sometimes created as 0 byte files - how to find and delete them in folders

Advertisement

waldimort
Donor
Joined:
Posts:
2

Empty folders on FTP sometimes created as 0 byte files - how to find and delete them in folders

I have a scheduled script uploading files and folders from my local computer. Sometimes empty folders are created as zero byte files. Found already threads to that topic but my logs were due to age already deleted. Will send it as soon it happen again.
Sadly the 0byte files will not be overwritten. Instead the next time the script runs it simply stumbles exits at that point. In the GUI it is quite convenient to find and delete the Zerobyte files. (mask: <1) How can I do that with script? The RM command seems to not offer options like sizefilter or including subfolders

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,518
Location:
Prague, Czechia

Re: Empty folders on FTP sometimes created as 0 byte files - how to find and delete them in folders

It's not possible with simple WinSCP scripting.
But it's easy with WinSCP .NET assembly and PowerShell (or other language of your preference).
Use Session.EnumerateRemoteFiles to list all files and filter those you are interested in.
https://winscp.net/eng/docs/library_session_enumerateremotefiles

Reply with quote

Advertisement

You can post new topics in this forum