I have a large list of folder names, and I am trying to find a script that will search a directory for each of these folder names and move them to another location if found. Since I am not a programmer, and assistance would be greatly appreciated.

Chris

8 Spice ups

Have you looked into it or done some research? What have you tried so far?

Do you have any snippets? If so please post them. If you post code, please use the ‘Insert Code’ button. Please and thank you!

Some things you want to look into:

Get-Childitem
Foreach-Object
where-object

1 Spice up

fox example looking for pst and moving

$sourceDir = 'C:\MyShadow'
$targDir = '\\server\EmailBackup\'

Get-ChildItem $sourceDir -filter "*.pst" -recurse | 
    foreach{ 
       
      move-Item $_.FullName -destination $sourceDir 
    } 
1 Spice up

I located a Powershell script that prompts for the directory to look in, and the folder name to search for. When testing searching a single document, I noticed the memory usage on the server continued to creep up, so I cancelled after a few minutes of running with no results:

<#
" Satnaam WaheGuru Ji"

Author : Aman Dhally
E-Mail : amandhally@gmail.com
website : www.amandhally.net
twitter : https://twitter.com/#!/AmanDhally
facebook: PowerShell User Group, New Delhi (India) | Facebook
Linkedin: http://www.linkedin.com/profile/view?id=23651495

Date : 13-Sept-2012, 11:43 AM
File : Find_Folder
Purpose : FInd Folders Using Powershell

Version : 1

#>
n" write-Host "---------------------------------------------" -ForegroundColor Yellow $filePath = Read-Host "Please Enter Folder Path to Search" write-Host "---------------------------------------------" -ForegroundColor Green $fileName = Read-Host "Please Enter Folder Name to Search" write-Host "---------------------------------------------" -ForegroundColor Yellow "n”

Get-ChildItem -Recurse -Force $filePath -ErrorAction SilentlyContinue | Where-Object { ($.PSIsContainer -eq $true) -and ( $.Name -like “$fileName”) } | Select-Object Name,FullName | format-Table * -AutoSize

write-Host “------------END of Result--------------------” -ForegroundColor Magenta

end of the script

delete this bit out of that script and you might start getting output:

| format-Table * -AutoSize

As it is, the script is buffering all the data that it finds because it has to format it nicely before dumping it to the screen.

I eliminated

| format-Table * -AutoSize

from the script and tried running again. memory continued to climb without displaying any result.

All answers are greatly appreciated. Unfortunately, I am not astute enough in scripting to create this from scratch.

Chris

Spoke to our development team and I’m going to get assistance from them to create a script. certainly appreciate everyone’s input and help.