我正在尝试创建一个脚本,该脚本读取文件的第一行,然后将具有类似命名约定的所有文件上移一个级别。
这些是 3 个示例文件:
C:\Users\USERNAME\location\PYYYYYYYYY.txt.asc
C:\Users\USERNAME\location\holdingarea\PYYYYYYYYY.tt.asc
C:\Users\USERNAME\location\holdingarea\PYYYYYYYYY.t.asc
我到目前为止的脚本是:
$location = Read-Host -Prompt "Location Filename"
$locationfilename = Select-String C:\Users\USERNAME\location\holdingarea\*.txt.asc –pattern $location -Context 1
$locationfilenames = $locationfilename.basename
$locationarea = "C:\Users\USERNAME\location\holdingarea"
$locationlocation = "C:\Users\USERNAME\location"
Select-String C:\Users\USERNAME\location\holdingarea\*.txt.asc -Pattern $location -Context 1 |
Out-File -Append C:\Users\USERNAME\location\logs.txt
Move-Item -Path "$locationfilenames" -Destination "$locationlocation"