Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Thanks for sharing your solution.
Ch33s3

as a small addition to whoever might find a need for this, this is my current workaround;

try
{
    $folderInfoSpec1 = Get-ChildItem -Path $localfolder -Filter *.mxf | Measure-Object -Property Length -Sum
    $folderCountSpec1 = $folderInfoSpec1.Count
    $folderSizeSpec1 = $folderInfoSpec1.Sum
    ###
    $folderInfoSpec2 = Get-ChildItem -Path $localfolder -Filter *.xml | Measure-Object -Property Length -Sum
    $folderCountSpec2 = $folderInfoSpec2.Count
    $folderSizeSpec2 = $folderInfoSpec2.Sum
    ###
    $folderInfoSpec3 = Get-ChildItem -Path $localfolder -Filter *.jpg | Measure-Object -Property Length -Sum
    $folderCountSpec3 = $folderInfoSpec3.Count
    $folderSizeSpec3 = $folderInfoSpec3.Sum
}     
finally
{
    $folderInfoSpec1Converted = $folderSizeSpec1 /= 1073741824
    $folderInfoSpec1ConvertedR = [Math]::Round($folderInfoSpec1Converted,2)
    #Write-Host "$folderCountSpec1 MXF Assets ($folderInfoSpec1ConvertedR GB) in total"
    ###
    $folderInfoSpec2Converted = $folderSizeSpec2 /= 1073741824
    $folderInfoSpec2ConvertedR = [Math]::Round($folderInfoSpec2Converted,2)
    #Write-Host "$folderCountSpec2 XML Assets ($folderInfoSpec2ConvertedR GB) in total"
    ###
    $folderInfoSpec3Converted = $folderSizeSpec3 /= 1073741824
    $folderInfoSpec3ConvertedR = [Math]::Round($folderInfoSpec3Converted,2)
    #Write-Host "$folderCountSpec3 JPG Assets ($folderInfoSpec3ConvertedR GB) in total"
    ### Combine all values
    $folderCountSpecCombined = $folderCountSpec1 + $folderCountSpec2 + $folderCountSpec3
    $folderInfoSpecCombined = $folderInfoSpec1ConvertedR + $folderInfoSpec2ConvertedR + $folderInfoSpec3ConvertedR
    Write-Host "$folderCountSpecCombined Assets with accepted filetypes ($folderInfoSpecCombined GB) in total"
    # Disconnect, clean up
    $session.Dispose()
}
Ch33s3

Enumerate local assets matching $transferoptions.filemask

Hi again,
I'd like to count all local assets matching my filemask, regardless of its state (already synced or not should not matter in this case)... is there a way to archive this with WinSCP ?
heres my approach, would you be so kind an help me out again on this one ?
# Connect
$session.Open($sessionOptions)
 
######FILEMASK-SETTING#######
$transferoptions = New-Object WinSCP.TransferOptions
$transferoptions.filemask=$acceptedExtensions
###############################
$LocalAcceptedAssets = $session.SynchronizeDirectories([WinSCP.SynchronizationMode]::Remote, $localPath, $remotePath, $True ,$True, [WinSCP.SynchronizationCriteria]::Size, $transferOptions)
$LocalAssetCount = 0
$LocalAssetCountSize = 0
foreach ($asset in $LocalAcceptedAssets)
{
    if (($asset.Action -eq [WinSCP.SynchronizationAction]::null) -or
        ($asset.Action -ne [WinSCP.SynchronizationAction]::null))
    {
        $LocalAssetCount++
        $LocalAssetCountSize += $asset.Local.Length
    }
 
}
Write-Host "$LocalAssetCount Assets ($LocalAssetSizeCountGBConvertedR GB) in total"
# Disconnect, clean up
$session.Dispose()

Have a nice day and thanks for your help !