Topic "Download only correct files from FTP to local folder"

Author Message
Pavel

Guest


Hello colleagues,

Could you please help me with change this wonderful script: https://winscp.net/eng/docs/library_example_delete_after_successful_download

We have special .DONE file on our FTP for each main file. This file created as flag when main file uploaded to FTP.
For example, typical structure of our FTP:
1.txt
1.txt.DONE
2.zip
2.zip.DONE
etc

I need download main file from FTP using this script only if .DONE file exist.

Many thanks for you help.
Advertisements
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26705
Location: Prague, Czechia
That's hardly related to this script you refer to.

And your specification is pretty vague.

Do you want to download one specific file? Or all files that have the .DONE folder?
Pavel

Guest


Hi Martin,

Thank you for feedback!

Step by step actions (concept):
1. Get list of files on FTP (only main files or only .DONE files or all files?)
2. Create list of main files which have .DONE file
3. Download this list of files (both main and .DONE)
4. Delete downloaded files from FTP (both main and .DONE)

After these actions only main files without .DONE will be stored on FTP.
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26705
Location: Prague, Czechia
This may help you to start:
https://winscp.net/eng/docs/library_example_listing_files_matching_wildcard

It will allow you to find all the .done files.
Then, instead of just printing them, you download the main files for each found .done file.
Guest




Hi Martin,

I understand that you are not powershell conultant Smile
But may be yo could help me with getting basename of file in this construction (filename without extension).

Thank you.

Code:
 foreach ($fileinfo in $files)
            {
             $session.GetFiles(
            ($remotePath + $fileName),
            ($localPath + $fileName)).Check()
       }
Pavel

Guest


Hi Martin,

Already found solution. I used string like "[System.IO.Path]::GetFileNameWithoutExtension($OKfile)"

Thank you Smile
Advertisements

You can post new topics in this forum

Search

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License