- #&cls&@powershell -c "Get-Content '%~0' | Select-Object -Skip 1 | Out-String | Invoke-Expression" & pause&exit
-
- $src_dir = './'; #源目录
-
- $files = Get-ChildItem -Path './' -Filter '*.xls' -Recurse -File
- foreach($file in $files)
- {
- $xl=New-Object -ComObject Excel.Application
- $xl.Visible = $false
- $wb=$xl.workbooks.open($file.FullName)
- $ws = $wb.worksheets.Item(1)
- $ColumnSelect = $ws.Columns("B:B")
- $ColumnSelect.Insert()
- $ws.Cells.Item(1,2) ='时间'
- $ws.Cells.Item(2,2) =$ws.Cells.Item(2,1)
- $ws.Cells.Item(2,1) = $ws.Cells.Item(1,1)
- $ws.Cells.Item(1,1)=$null
- $ws.Cells.Item(1,9) = '账上余额'
- $wb.Save()
- $xl.Quit()
- while([System.Runtime.Interopservices.Marshal]::ReleaseComObject([System.__ComObject]$xl)){'released'| Out-Null}
- }
复制代码 用法:设置源目录(如果脚本与文件同目录,则不用改),保存为bat执行。 |