Clean Up of duplicated files

rated by 0 users
This post has 1 Reply | 1 Follower

Top 500 Contributor
Posts 2
Vince Butler Posted: 02-07-2010 9:30 PM

Hi,

I have a folder structure that I need cleaning up for duplicate files, but I cant seem to get the syntax right.

I have a bunch of folders with the following structure

Top
   In
     Supplier1
        OrderConf
        Invoice
           Proc
           Work
     Supplier2
         OrderConf
          Invoice
             Proc
             Work

So documents come in from outside into the Work folder for each supplier.  They are then picked up (by an AS/400 using FTP) and FTP renamed to the Proc Folder.  This process dies horribly when the file already exists in the Proc folder by looping on that document.  How can I pick up all duplicate files (XML's, by name) for all instances of Work that already exist in Proc and move them elsewhere?

Thanks for your help, my skills with PS are still rudimentary.

Vince.

Top 500 Contributor
Posts 2

Just a hint would be great.  I'm mainly having problems with looping around a foreach in the Supplier level and then looping in the files in the "Work" folder.  i can do one, or the other, but not both. i.e.  Sorry this is such a basic question, but I'm obviously missing some basic knowledge.

Push-Location
Set-Location 'D:\Top\In\'
function ShowDuplicates()
{
  get-childitem work | foreach { get-childitem 'Invoice\Proc\'$_.Name }
}


$dirs = Get-childitem | Where-Object { $_.PSIsContainer }

$dirs | foreach { Push-Location | Set-Location $_.Name | ShowDuplicates | Pop-Location }

Pop-Location

This doesn't work, but I can test each bit and it works independently in that environment.  I apologise for my dumbness and thank you for any help.

Vince.

Page 1 of 1 (2 items) | RSS
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.