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

Popular posts from this blog

directory stack

After enabling Windows Server 2012 R2 DHCP Failover Getting Packet dropped because of Client ID hash mismatch

WMI Repository 4GB limit - Win 2003 Ent Question