How to move downloaded file to another directory

I download a csv file and have it renamed via onDownload command. Next, I want to move the file I just downloaded to a specific directory.

The file has a variable name:
{dateToday} some fixed text.csv where {dateToday} = yyyy/mm/dd
e.g. file name
2020/10/17 some fixed text.csv

It saves in the ‘downloads’ folder, and I want to move it to another directory. I have read in the forums you can do this with powershell or python or a batch file though I really don’t know how to use any of those. What would the code look like? Would I write a .ps1 file and save it, then call XRun to that ps1 file? And what do the contents of the ps1 file need to be? The file name to move is variable - is there a way to say move ‘most recent’ file? Or is a better idea to store the file name in a variable like this:

store | {dateToday} some fixed text.csv | filename onDownload | {filename} | true

Then if I do XRun on a powershell file, can I reference the ui.vision ${filename} when telling it which file to move? Is that possible? I’m just trying to figure out 1. how to move a file and 2. what the best way is.

I came up with this simple powershell script to move the most recently created file. It works but if anyone has any better ideas I’d be happy to learn from them.

$source = “C:…”
$destination = “D:…”

@(Get-ChildItem source | Sort CreationTime -Descending)[0] | % { Move-Item -path _.FullName -destination $("$destination") -force}

You did it correct, I have a few macros that do the same thing. If it’s a simple move I’ll just do move /Y in a batch file or if I need to do something more complicated or with logic I’ll do a script like you just did.

1 Like

You can use batch file with MOVE command

1 Like