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

Export File pairings with same name in same folder based on size

$
0
0

I have a folder that contains file pairs with the same name but different extensions.  Each file pair resides in the same folder, but there are sub-folders that contain additional file pairs I want to capture as well.

In every case, 'file1.name' = 'file2.BaseName'. example: "myfile.sla" & "myfile.sla.slb" and the extensions will always be '.sla' & '.slb'

I need to identify only those pairings where the size of 'file2' is -ge 20% of the size of the 'file1', then export those to CSV. 

The script below works on a single folder with a single pair, but I need some help getting this to work for multiple pairs in a folder and subfolders.  As i mentioned before, the ultimate goal is to export each pairing to CSV with its name and size.

---------------------------------

$file1 = Get-ChildItem -path "I:\FILES" -recurse -include *.slb

$file2 = Get-ChildItem -path "I:\FILES" -recurse -include *.sla

$filepair = ($file1.length / $file2.length)

if ($filepair -ge .20) {$filepair}

-----------------------------------

Thanks in advance for any insight you can provide!


Viewing all articles
Browse latest Browse all 6937

Trending Articles