1

I'm trying to clean up a emcopy that went wrong. I've compared the source and destination directories and identified what needs to be removed from a shared drive. I have a couple folders and subfolders that need to be addressed first. I've created the below script however it doesn't seem be able to move the files successfully (moves some files but some files contain commas and other characters and those files seem to be skipped as well as some subfolder files). Also the final destination directory is where the files should be moved to in the case that something was moved incorrectly. Thank you in advance for all your help and as you can see i'm new to powershell and coding.

$Destination = "\\SAN\Share\Backup"
import-csv "D:\Folder.csv" -Header Folder | ForEach-Object {
$FinalDestination = Join-Path $Destination -ChildPath $_.Folder
New-Item -ItemType Directory -path $FinalDestination -Force
}
import-csv "D:\File.csv" -Header File |
ForEach-Object {
Move-Item -LiteralPath $_.File -destination $FinalDestination -Force
}
  • 1
    Please give example input and output. Read about MCVEs. – philipxy Dec 17 '15 at 21:59
  • input (script shown above) CSV example Folder.csv (only single column CSV) Folder\Folder\Folder CSV example File.csv (also only single column CSV) \\SAN\Share\FolderName\FolderName\FolderName\file.doc(.pdf, .xls, ...etc) output = Move-Item : Cannot move item because the item at ' \\SAN\SHARENAME\SubFolder\SubFolder\file, filenamestill, filenamestill.doc' does not exist. -this file does actually exist and there are roughly 3500 items that i need to move. Thanks and please let me know if i can provide you with any more detail – Philip Dale Dec 17 '15 at 22:08
  • Please edit that into your question. Please give *all* input for an example. Eg the contents of directories. – philipxy Dec 17 '15 at 22:16
  • maybe I'm wrong, but it looks like all your files will be copied to the last folder in your folder list – Anthony Stringer Dec 17 '15 at 22:23
  • \\SAN\share\folder\folder\Outstand invoices, Customer converted to new VC provider.doc is an example of one of the folder contents that isn't moved by the script. – Philip Dale Dec 17 '15 at 23:14
  • \\SAN\share\folder\folder\Security Account Seizure.doc is an example of a file that is copied by the script. Thanks philipxy Anthony thanks for the comment. I thought it was a similar issue as i was having with the certain file types not being copied but you are correct everything is copied into the last folder of the list. Something else for me to troubleshoot – Philip Dale Dec 17 '15 at 23:30

0 Answers0