我必须在powershell中构建一个脚本来执行这些任务:
我批量尝试了一些脚本,但我想我得搬到powershell.
第一步:我尝试使用以下内容读取文件夹的名称:
Get-ChildItem -Recurse -Directory | Select Name, @{ n = 'Foldername'; e = { ($_.PSPath -split "-")[1] } }
但我必须提取名字的左边,而不是右边。
发布于 2020-12-29 17:02:59
这样的做法如下:
H 210G 211$sampleDirectory = Get-Item -Path C:\PathTo\yourSample\Directory
$Folders = Get-ChildItem -Directory -Path C:\PathTo\YourFolders
ForEach ($folder in $folders){
$folderName = $_.Name.Split("-")[0]
Copy-Item $sampleDirectory -Destination $folder
#Play with the syntax here to get your ideal name
$desiredName = $folderName + "whatever.xls"
Get-Item $folder\sample.xls | Rename-Item -NewName $desiredName -WhatIf
}这应该能让你走
https://stackoverflow.com/questions/65494166
复制相似问题