I have a code like this:
$txt = get-content c:\work\test\01.i
$txt[0] = $txt[0] -replace '-'
$txt[$txt.length - 1 ] = $txt[$txt.length - 1 ] -replace '-'
$txt | set-content c:\work\test\01.i
It just removes a - from first line and last line in a text file, but I need to do this for all text files in the directory tree which contains over 5k text files. how should I modify this code?
All name of text files are random.
I need to do this in powershell.
Its a directory tree, under c:\work\test there will be more lvl of sub-folders then contains all text files.
Please help . thanks
Get all files by file extension or something a pattern and loop through them. Lets say it’s all the files with
.iextension. Try: