Re: [問題] 批次修改資料夾名稱

作者: falcon (falken)   2022-04-17 04:05:01
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

Links booklink

Contact Us: admin [ a t ] ucptt.com