0

I am trying to write a short powershell MOVE-ITEM command that takes rows of data from a CSV and moves the file from the folder it is in to a separate folder (which already exists).

I've looked at various examples and I think I'm pretty close but I'm getting an error when I run the command. The error is illustrated below:

MOVE-ITEM : Cannot find path 'C:\Users\blank\Downloads\move-files-test-area\@{Filename=Testdoc1}' because it does not exist.

I'm actioning this from within the directory and I'm obviously missing one piece that cleans up the MOVE-ITEM file path but I can't fathom what it is.

The command in full is:

IMPORT-CSV -PATH process-docs.csv -ERRORACTION STOP | foreach {MOVE-ITEM -PATH $_ -DESTINATION \to-here\ }

What blindly obvious thing am I missing? I don't use powershell often but I have 100k files to sort from a separate set of 400k files and I have no wish to handle it manually so I've been exploring the MOVE-ITEM command to aid me.

To confirm, I'm running this in Windows Powershell just in case that has any importance for suggestions.

Thanks for any help on this.

BoBFiSh
  • 102
  • 9
  • 2
    `IMPORT-CSV … | select -ExpandProperty Filename | foreach { … }` ? While debugging, use `Move-Item -WhatIf …`. – JosefZ May 03 '23 at 16:00
  • Hi @JosefZ I've gone through that and that has helped me resolve the issue. I need to work a little on the end destination it seems but all seems to be working now that I've included that Select portion. – BoBFiSh May 05 '23 at 12:22

0 Answers0