title: Saving as a new file using input filename and just adding some suffix - Powershell
body: <p>So i know the title is confusing and i apologize for that.  </p>
  
  <p>What i need to do is not write in the same file which can be easily done by just putting a path and name and it will create file for me at that path.  </p>
  
  <p>But that's not what i want to do i want to take the input file name and add a suffix to it so for example input file name was <code>ABB</code> after adding suffix it would become <code>ABB-Clean</code> ...  </p>
  
  <p>How i can achieve that with Set-Content or is there anyother way which will not require me to change the code.</p>
  
  <pre><code>Function Get-FileName($initialDirectory)
  {
  [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | 
  Out-Null
  
  $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
  $OpenFileDialog.initialDirectory = $initialDirectory
  $OpenFileDialog.filter = "SCD (*.scd)| *.scd|CID (*.cid)| *.cid|ICD (*.icd) | *.icd | All Files| *.*"
  $OpenFileDialog.ShowDialog() | Out-Null
  $OpenFileDialog.filename
  }
  #"C:\Users\UserName\Desktop"
  $inputfile = Get-FileName
  #$inputdata = get-content $inputfile
  
  #$configFiles = Read-Host 'Enter Complete directory to file'
  (Get-Content $inputfile -Raw) |
  Foreach-Object { 
  $_  -replace '&lt;Terminal .+\/&gt;', '' `
      -replace '(?s)&lt;Terminal .*?&gt;(.|\s)*?&lt;/Terminal&gt;', '' `
      -replace '(?s)&lt;Private type="ABB.*?&gt;(.|\s)*?&lt;/Private&gt;', '' `
      -replace '(?s)&lt;ConnectivityNode.*?&gt;(.|\s)*?&lt;/ConnectivityNode&gt;', ''       
  } |
  
  Set-Content Rename-Item "Clean - " + $inputfile 
  
  (GC $inputfile)|?{$_.Trim(" `t")}|SC $inputfile
  </code></pre>