Ank*_*kit 0 windows shell powershell
我有以下需要修改的Power Shell脚本.
$filepath = "F:\feeds\Amazon\"
$temppath = $filepath+"temp.csv"
$files = ls -Path $filepath *.csv
foreach ($file in $files){
gc $file.FullName |
% { if($_.indexOf("|~|") -eq -1) {$_ -replace "`"((?:`"`"|.)*?)`"(?!`")", "|~|`$1|~|" -replace "`"`"", "`""} else {$_ -replace " ", " "}} |
sc $temppath
ri $file.fullName
rni -Path $temppath -NewName $file.fullName
}
Run Code Online (Sandbox Code Playgroud)
此脚本循环遍历已定义文件夹中的所有.csv文件,并更改文本限定符.现在我需要改变一点,我被困住了.
基本上我的CSV文件被插入到多个文件夹中.Amazon1,Amazon2,Amazon3 ..等等.有没有什么外卡匹配我可以在这里做的事情,以便它查看所有名称以亚马逊开头的文件夹?
我不想循环浏览文件夹.
...... *角色?试试这个:
$filepath = "F:\feeds\Amazon*"
$files = ls -Path $filepath *.csv -recurse
foreach ($file in $files){
$temppath = $file.directoryName+"\temp.csv"
gc $file.FullName |
% { if($_.indexOf("|~|") -eq -1) {$_ -replace "`"((?:`"`"|.)*?)`"(?!`")", "|~|`$1|~|" -replace "`"`"", "`""} else {$_ -replace " ", " "}} |
sc $temppath
ri $file.fullName
rni -Path $temppath -NewName $file.fullName
Run Code Online (Sandbox Code Playgroud)
}