我有一个文件夹,其中包含一组文件,它们的名称类似于07777123456-02071234567.dat
我需要对文件夹中的每个文件运行可执行文件,如下所示:myexecutable.exe -orignum=07777123456 -destnum=02071234567 -file=07777123456-02071234567.dat
我最近的尝试是这样的:
$fileDirectory = "c:\PS";
foreach($file in Get-ChildItem $fileDirectory)
{
Write-Output "Processing: $file"
$phonenumbers = $file.split("-")
Write-Output "Originating Number: $phonenumbers[0]"
Write-Output "Destination Number: $phonenumbers[1]"
}
#myexecutable.exe -orignum=$phonenumber[0] -destnum=$phonenumber[1] -file=07777123456-02071234567.dat
我尝试了Get-ChildItem
,File-Split
等的各种组合。我不断收到类似的错误:
方法调用失败,因为[System.IO.FileInfo]不包含名为'split'的方法。
有任何建议解决此问题吗?
好吧,我知道了。必须终于醒了。