Set-Content should work fine with some minor adjustments. Here is an example of how it should work (this is everything within your outer foreach loop):
$csvFile = $file.BaseName
if (!(get-childitem ./ |where-object {$_.Name -like $csvFile})) #check whether file has been processed
{
(gc $file | foreach {
$_.Insert($columBreaks[0],",").Insert($columBreaks[1],",").Insert($columBreaks[2],",").`
Insert($columBreaks[3],",").Insert($columBreaks[4],",").Insert($columBreaks[5],",").`
Insert($columBreaks[6],",").Insert($columBreaks[7],",").Insert($columBreaks[8],",").`
Insert($columBreaks[9],",").Insert($columBreaks[10],",")
}) | set-content $csvFile #note parenthesis around everything that gets piped to set-content
}
By the way, instead of splitting the filename on the '.', you can just get the name without the extension by using $file.BaseName
:
$csvFile = $file.BaseName + ".csv"
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…