Windows 命令处理器 FOR 循环搜索与模式匹配的文件和 运行 每个文件的 EXE 的 PowerShell 等价物是什么?
What is the PowerShell equivalent for a Windows Command Processor FOR loop searching for files matching a pattern and running an EXE with each file?
我在批处理文件中有这个 Windows 命令行:
for %%f in (*fla) do fla2comp.exe -d "%%f"
命令行在 PowerShell 语法中看起来如何?
fla2comp.exe
在批处理文件的目录下
解析当前文件夹中匹配通配符名称的所有文件*fla
:
Get-ChildItem -File -Filter *fla
要遍历每个文件,将输出通过管道传输到 ForEach-Object
cmdlet:
Get-ChildItem -File -Filter *fla |ForEach-Object { <# $_ will contain a reference to each file here #>}
然后将每个文件对象的 FullName
属性(它将包含根文件路径)传递给 fla2comp.exe
:
Get-ChildItem -File -Filter *fla |ForEach-Object {
fla2comp.exe -d $_.FullName
}
我在批处理文件中有这个 Windows 命令行:
for %%f in (*fla) do fla2comp.exe -d "%%f"
命令行在 PowerShell 语法中看起来如何?
fla2comp.exe
在批处理文件的目录下
解析当前文件夹中匹配通配符名称的所有文件*fla
:
Get-ChildItem -File -Filter *fla
要遍历每个文件,将输出通过管道传输到 ForEach-Object
cmdlet:
Get-ChildItem -File -Filter *fla |ForEach-Object { <# $_ will contain a reference to each file here #>}
然后将每个文件对象的 FullName
属性(它将包含根文件路径)传递给 fla2comp.exe
:
Get-ChildItem -File -Filter *fla |ForEach-Object {
fla2comp.exe -d $_.FullName
}