Link to home
Start Free TrialLog in
Avatar of _agx_
_agx_Flag for United States of America

asked on

How to modify the $_.Group in this script to display a full file path

I want to find duplicate files on my local computer, based on file content.  This script on github seems to do the trick. My PowerShell skills are poor, but I  grok enough to see what it's doing and how.  

I also want print out the full path of both files instead of just the two file names.   Unfortunately that's beyond  beyond my limited PS skills, even after reading this article on group.  

Anyone know how to modify the $_.Group  to display the full paths of the two files?

(I'd be happy to post what I've tried, but it's embarrassingly NON-functional... )
SOLUTION
Avatar of footech
footech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of _agx_

ASKER

Thanks, I've been struggling through examples for about an hour to do something even close to that ;-)  

Basically I just want to print a list of dupe counts and the full paths to the files.  I can reformat it, but basically something like one of these:

Count = 2                                <=== Total count
c:\temp\myfile.ext                 <=== List of duplicate files with full path
c:\other\myfile.ext

Count = 3
c:\temp\myfileA.ext
c:\other\myfileA.ext
c:\other\otherFile.ext

==== OR =====

Count  | Hash | Fullpaths 
2 | xxxxxxxxxxxxxxxxx |  c:\temp\myfile.ext, c:\other\myfile.ext
3 | xxxxxxxxxxxxxxxxx |  c:\temp\myfileA.ext, c:\other\myfileA.ext, c:\other\otherFile.ext

Open in new window

That will be determined by the properties of the objects grouped together, and whatever internals to the Group-Object cmdlet.

Yeah, makes sense. From what I was reading, "format-table" could be used to alter the the display of the object. But ... I couldn't figure out if it's possible to alter the grouped "object" in such a way that it could also store other properties, like a list of files. Does that kind of grouping *only* produce a COUNT or could you add other properties to it, like an array of file names?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of _agx_

ASKER

Thanks all!
@footech - That helps me better understand Group.
@oBdA - Works and great example to study.