Having An Issue With PS1 To Find String & Use To Rename File
i have ps1 below - not throw errors in debug or run, doesn't rename of file i'm looking for.
$files = ((get-childitem $dir).name -like "hsbc_fr*.txt") foreach ($file in $files) {$val1=(get-content $file | select-string -pattern "eur") $newname = $val1 + "france" + ".txt" rename-item $file -newname $newname}
script dips file , finds string eur, use rename file "eurfrance.txt"
confused since no errors show - missing?
start formatting code correctly:
$files = (get-childitem $dir).name -like 'hsbc_fr*.txt' foreach ($file in $files) { $val1 = get-content $file | select-string -pattern 'eur' $newname = "$val1france.txt" write-host $newname -fore green rename-item $file -newname $newname -verbose }
\_(ツ)_/
Windows Server > Windows PowerShell
Comments
Post a Comment