[System.Reflection.Assembly]::LoadFrom('c:\DsoFile\Source\Vb7Demo\bin\Interop.DSOFile.dll') function SetSummary-Name([string] $folder, [string]$pattern = '*.*') { $files = [System.IO.Directory]::GetFiles($folder, $pattern) foreach ($f in $files) { $oled = New-Object -TypeName DSOFile.OleDocumentPropertiesClass $oled.Open($f, $false, [DSOFile.dsoFileOpenOptions]::dsoOptionDefault) $sp = $oled.SummaryProperties $sp.Title = $f.Substring($f.lastindexof('\') + 1, $f.lastindexof('.') - $f.lastindexof('\') - 1) $oled.close($true) } } SetSummary-Name -folder 'c:\photo'
# function RandomName([string]$path) { $length = 20 # $sb = New-Object -TypeName System.Text.StringBuilder for($i=0; $i -lt $length; $i++) { # , ... [char]$ch = [Convert]::ToChar([Convert]::ToInt32([Math]::Floor(26 * $rand.NextDouble() + 65))) $tmp = $sb.Append($ch) # Append , $tmp } $name = $path.Substring($path.lastindexof('\') + 1, $path.lastindexof('.') - $path.lastindexof('\') - 1) $sb = $sb.ToString().ToLower() return $path.Replace($name, $sb) } function MixFiles([string]$From, [string]$pattern = '*.*') { $files = [System.IO.Directory]::GetFiles($from, $pattern) foreach($f in $files) { $path = RandomName -path $f # , while([System.IO.File]::Exists($path)) { # , $path $path = RandomName -path $f } # Write-Host ($f + ' -> ' + $path) [System.IO.File]::Move($f, $path) } } $rand = New-Object -TypeName Random MixFiles -from 'c:\test\' -pattern '*.jpg'
Source: https://habr.com/ru/post/144888/
All Articles