Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

replace text script help

$
0
0


 I need some help adding some more logic to this script. When I find the files I need to do a extra check before doing my 
replace. Then after files matches or not I need to move this file to another folder. If file already exist in Dest folder
I just need to append to file name. If it's NEW than a simply MOVE to Dest folder.

This is what I have so far.  I added comment where I need to add new Logic.

$match = "ST*862*"
$replacement = "ST*860*"
$destcopy = 'c:\TestBackup'
$files = Get-childItem –filter *.msg -path "C:\test\"

foreach($file in $files)
{

 # Before I do replace I need another check inside same row for "REF*MF*" then find  char "~"  on same row.
 # If there are more than 8 characters between the "~" and "REF*MF*"  Then DO Replace in script..

((Get-Content $file.fullname) -creplace $match,$replacement) | set-content $file.Fullname
}

  # Need to add the MOVE or APPEND logic here


 Thanks.


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>