powershell - 从 foreach 中的文本文件复制
问题描述
我正在尝试复制一个文本文件(一次一行),打开记事本++,在一行上运行一个宏,然后将该文本附加到另一个文件中。它完美地运行宏,但是它完全忽略了 $changefile 中的文本,只复制了 $exportfile。这是我到目前为止所拥有的
$exportfile=$args[0]
$changefile="Changefile.txt"
$inputfile="tick-import.txt"
$wshell = New-Object -ComObject wscript.shell;
$statement = get-content $exportfile
$newstatement = get-content $changefile
Start notepad++ $changefile
foreach($line in $statement) {
$line | out-file -Filepath $changefile
Sleep 2
$wshell.SendKeys("^%1")
Sleep 1
foreach($line in $newstatement) {
$line | out-file $inputfile -Append
}
}
第二个 foreach 是行不通的。
解决方案
推荐阅读
- python - 根据条件,将 pandas 数据框中的特定值替换为相应的列名,
- elasticsearch - 从 Elasticsearch 存储桶中获取最高值
- redisson - redisoon 错误:Redis url 应该以 redis:// 或 redis:// 开头
- amazon-web-services - 当项目包含列表 AttributeValue 时,Terraform aws_dynamodb_table_item 资源失败
- java - 在 java 中进行定时输入,同时显示倒数计时器
- amazon-web-services - 如何为 AWS Sagemaker 托管的自定义 Tensorflow2 模型使用多个输入
- python - 如何在 Pipfile 中指定特定于平台的附加功能或版本?
- android - 如何从下载文件夹中选择的 Uri 获取绝对路径?
- python - 在 python (selenium.webdriver.firefox.webelement) 中查找 selenium 中的细分
- google-maps - 如何隐藏 Google Maps API 本地上下文地图的上下文侧边栏