Re: [問題] 批次修改資料夾名稱
Function Main
{
Create-MultipleFolders -Title "X" -Amount 999
}
Function Create-MultipleFolders
{
param (
[string]$Path = '',
[string]$Title = '',
[int]$Amount = 1)
if ($Path.Length -eq 0) {$Path = $pwd.path}
for ([int]$i = 1; $i -le $Amount; $i++)
{
[string]$TitleWithNumber = '{0}{1:d3}' -f $Title, $i
[string]$TargetFullName = $Path.Trim().Trim('\') + '\'
+ $TitleWithNumber
New-Item -Force -ItemType 'directory' -Path (
$TargetFullName -replace '([\`\[\]])', '`$1')
}
}
Main
https://i.imgur.com/BvkQu5Z.png
--
Sent from PTTopia
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 110.28.6.173 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Windows/M.1650139503.A.0AD.html
※ 編輯: falcon (110.28.6.173 臺灣), 04/17/2022 04:08:02
※ 編輯: falcon (110.28.6.173 臺灣), 04/17/2022 04:13:23
※ 編輯: falcon (110.28.6.173 臺灣), 04/17/2022 04:14:54
※ 編輯: falcon (110.28.6.173 臺灣), 04/17/2022 04:18:49
討論串 (同標題文章)
完整討論串 (本文為第 2 之 7 篇):
問題
4
25