需求:
http://bbs.bathome.net/thread-45052-1-1.html
批量修改txt文件,分隔符是“,”,形如:
...
编号11,15.5,11.7,14.4,19.7,3163897,36593100.00
编号12,15.5,11.7,13.9,18.6,2376942,27510228.00
...
然后修改,将最后一列去掉,将第五列数据再粘贴一次到最后面,就好像:
...
编号11,15.5,11.7,14.4,19.7,3163897,19.7
编号12,15.5,11.7,13.9,18.6,2376942,18.6
...
代码:- $folder = "bathome.net"
- New-Item "$folder" -ItemType directory
- Get-ChildItem *.txt | %{
- $NewName = $folder + '\' + $_.Name
- Get-Content $_ | %{
- $a = $_ -split ','; $a[6]=$a[4]; $a -join ','
- } | Out-File "$NewName"
- }
复制代码
|