3
我正在尝试创建一个脚本,它读取文件的第一行,然后将所有具有类似命名约定的文件移动到一个级别。读取输入和移动具有相似名称的文件
这些都是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"
加1用于'$ locationlocation' – Naigel
你的脚本有什么问题? –
它带回以下错误, Move-Item:找不到驱动器。名称为'> C'的驱动器不存在。 在行:10字符:10 +移动-项目<<<< -path “$ paymasterfilenames” -Destination “$ paymasterlocation” + CategoryInfo:ObjectNotFound:(> C:字符串)[移动-项目],DriveNotFoundException + FullyQualifiedErrorId:DriveNotFound,Microsoft.PowerShell.Commands.MoveItemCommand –