I'm super new to PowerShell, usually just using one line commands to get things done, but have been asked if I can take a batch of postscript files that are created from a mainframe and rename them based on the first line of that file then move them to a network location.
I've done a bit of research on google, but everything I've found talks about retrieving text from files and writing to a new file.
Any help would be greatly appreciated.
Edit:
It seems it will be easier if the text will be the last line of the file instead of the first. I've gotten it set so that I can do a single file name changed using the code below. Now just to get it setup to do all files in a directory.
$orgfilename = 'c:\postscript\test.PS'
$tempfilename = Get-Content $orgfilename | Select-Object -Last 1
$newfilename = $tempfilename.Substring(3)
move-item $orgfilename c:\newlocation\$newfilename'.ps'
I added the .Substring(3) to ignore the " %" (space%) in the file.