本帖最后由 flashercs 于 2022-8-11 19:33 编辑
批处理保存ANSI编码,放到csv 目录下.- <#*,:&cls
- @echo off
- cd /d "%~dp0"
- powershell -C "Set-Location -LiteralPath ([Environment]::CurrentDirectory);. ([ScriptBlock]::Create((Get-Content -LiteralPath \"%~f0\" -ReadCount 0 | Out-String)))"
- pause
- exit /b
- #>
- # 新工号列表
- $data = @"
- 范威亚 ZZ001
- 周栋栋 ZZ002
- 段胜男 ZZ003
- 张婷 ZZ004
- 张功政 ZZ005
- 谭圆圆 ZZ006
- 侯强科 ZZ007
- 杜亚明 ZZ008
- 潘施茂 ZZ009
- 杨乐 ZZ010
- 杜克新 ZZ011
- 李宁宁 ZZ012
- "@
- $dic = @{}
- foreach ($line in $data.Trim() -split '\r?\n') {
- $k, $v = -split $line
- $dic[$k] = $v
- }
- Get-ChildItem .\*.csv | ForEach-Object {
- $_ | Resolve-Path -Relative
- (Import-Csv -LiteralPath $_.FullName -Encoding Default) | ForEach-Object {
- # 更改工号
- $userName = $_.坐席姓名
- if ($dic.ContainsKey($userName)) {
- $_.坐席工号 = $dic[$userName]
- }
- $_.外包序列号 = $_.外包序列号 -replace '^GF[^-]*-'
- $_
- } | Export-Csv -LiteralPath $_.FullName -Encoding Default -NoTypeInformation
- }
复制代码
|