Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Search and Move files with powershell

$
0
0

Thank you all for helping me in this issue.

Experts,

 

I have large database of files, let's say more than 50,000.

I need to search a 7,000 thousands files which is listed in csv.

I need to search and move those files to different folder. I am using below script. I dont know is it working or is it really slow. because I don't see any results. Please help me in this issue I really appreciate it.

$data = Get-Content -Path 'csv path'

$path = 'files stored path'

$destinationPath = 'destination path'

$count = ""

foreach ($line in $data) {

    Get-ChildItem -Path $path -Recurse | Where-Object {$_.PsIsContainer -eq $false} | ForEach-Object {

       if ($line -like $_.name) {

            $dest = $destinationPath +  '\' + $_.Name

            Copy-Item -Path $_.FullName -Destination $dest

        } 

    }

}


Viewing all articles
Browse latest Browse all 6937

Trending Articles