Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

SalientAnimal

The new files are only created once a day. Which is why I download them daily. After which I then need to somehow move the original files on the FTP server into a backup directory.
martin

Re: Get files from Host, and rename on Server

You do not need two different scripts for this. Just use the mv command after the get.

Though note that this is not transactional. What, if a new file is added between the download and the move?

You can do this:
- Move the files before download to some temporary remote folder
- Download the files from there
- Move the files from the temporary folder to the archive folder

Or use WinSCP .NET assembly from PowerShell script. This will allow you to enumerate and move only the files that were really downloaded.
See these similar examples:
https://winscp.net/eng/docs/library_example_delete_after_successful_download
https://winscp.net/eng/docs/script_local_move_after_successful_upload
SalientAnimal

Get files from Host, and rename on Server

I have creating my script file in a text file as per the documents.

The part that I wasn't 100% sure of was when the file was being downloaded, is wasn't downloading the files as they were on the server. I had made a minor error on in my script which I have since figured out.

The part I haven't started working on, is how to, once the file is on my server, and once it has been "processed" to then be moved to another directory and renamed.

I would assume though, that I would require more than one text file, and that they would need to be executed by two different .bat files.
SalientAnimal

Get files from Host, and rename on Server

Hi All,

I want to automate the process of getting files from an external FTP site, as doing this manually daily is quite tedious.

The files are created daily, and only a part of the file name remains consistent each day. There are 5 files, that need to be fetched every single day (Monday - Sunday) from an external FTP server.

At this point in time, I have absolutely no idea where to start, except for knowing that my best bet would probably be to create a batch file, and to have it execute the required script.

Could someone please talk me through how I go about creating a script that will do the following:
Get the 5 files from the external server daily
Rename the files on the destination server daily
Move the source files into a "downloaded folder" on the source server
Move the files on destination server to a "imported directory" only at the end of the day, renaming them by adding a time stamp to the file name.

I would really appreciate as much help as possible here, as I don't have a lot of time to get this setup, and I am unfortunately not making much sense of the WinSCP documentation.

I am running a Windows Server

Thanks.