Copy/Move download file with a different name

Hay, I need download file and then change it, how can I download that file and then move in different folder to work with it. But my file name is like blabla02.03.2019. and some random numbers after that and each file have different numbers blabla is always the some, date is changing standard, but that random number is different for each file. Haw can I tell activity - move file to do that, that every time take correct file. Or maybe if it’s possible to take a last download file?


Try this:

strFiles = Directory.GetFiles(“FolderPath”,“filename”)

It will give you all matching files in that folder and then use Move File activity to move files.

1 Like

Hi @Tinkerbell,
You can also work with PowerShell

$path = "(path to folder)"
ls $path | sort-object -Property {$_.Name} | Select-Object -Last "1" | Move-Item - Destination" (path to folder where file need to be placed)" -Force

Sory, I didn’t use that, so I have questions. Do you mean I need to use Invoke Power Shell or what else? And where I need to write that?


You can sort the file array by descending on created date and then pick the first record which should be ideally the last downloaded file.

FileInfo files = dir.GetFiles().OrderByDescending(p => p.CreationTime).ToArray();

Here you have very nice tutorial how to handle with PowerShell with Invoke PowerShell activity: