Download files and append new value to the existing name

Advertisement

stijacicn
Joined:
Posts:
5
Location:
sweden

Download files and append new value to the existing name

Hello,

I need your help.. I have made a PS script which is working just fine, but now I would like to add today date into a file name... For example files that I am downloading are named test1.zip, test2.zip, etc... and for bulk download I am using in
$FilesToRetrieve = "test*.zip"
$transferResult = $session.GetFiles($FilesToRetrieve, $DestinationPath, $False, $transferOptions)
For Destination path I am assigning following value: "C:\Downloads\20200903_*"
and this is working, but not in a nice way and I am not able to find why... it assigns new value (date) but it cuts off old name, so for example it place new name like 20200903_st.zip
Hope that I explained well... Thanks in advance!
Regards,
Nikola

Reply with quote

Advertisement

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

Re: Download files and append new value to the existing name

It's not possible to add a prefix, when downloading the files selected using a file mask.
You would have to retrieve the file list (Session.ListDirectory) and download the files one by one.
Or change the naming strategy to add a suffix instead.

Reply with quote

Advertisement

You can post new topics in this forum