Observe that the solution below will not work if there are several files with the same file name. The only thing you'll need to add then is some form of source base address (from which the file structure is built) and a destination base address and just build the new destination path based on these.
$copyChangesSince = Get-Date "2014-01-08"
$doNotCopyChangesNewerThan = Get-Date "2014-02-02"
get-content .\files.txt | Foreach {
Get-Item $_
} |
Where { $_.LastWriteTime -gt $copyChangesSince -AND $_.LastWriteTime -lt $doNotCopyChangesNewerThan } |
Select FullName, Name |
Export-Csv C:\temp\filelist.csv -NoTypeInformation
Since you only want to copy a single item at a time I'm not sure I see the benefit of using robocopy. In my example below, I've just used Copy-Item. If you really want to use robocopy it shouldn't be hard to replace that call with a call to robocopy.
Import-Csv C:\temp\filelist.csv |
Foreach { Copy-Item -Path $_.FullName -Destination "C:\temp\output\$($_.Name)" }
If you don't want to actually use the .csv-file afterwards, you could just as easily skip that part and replace the Select
and Export-Csv
with the Foreach
statement from the Import-part (and of course skip the Import-Csv
as well).
Edit: Split the process into two parts, as was requested in the question.