本帖最后由 newswan 于 2021-8-6 12:28 编辑
powershell- function f-1()
- {
- push-location $args[0]
- $p = (get-item .).name
- Get-ChildItem -Directory | foreach-object {
- Rename-Item $_ -NewName ($p + "-" + $_.name)
- }
- Get-ChildItem -Directory | foreach-object {
- f-1 $_.name
- }
- pop-location
- }
-
-
- function fl-1()
- {
- push-location $args[0]
- $p = (get-item .).name
- $count = 0
- Get-ChildItem -File "*.txt" | foreach-object {
- $count += 1
- Rename-Item $_ -NewName ($p + "-" + $count.ToString().PadLeft(2,"0") + $_.Extension)
- }
- Get-ChildItem -Directory | foreach-object {
- Rename-Item $_ -NewName ($p + $_.name)
- }
- Get-ChildItem -Directory | foreach-object {
- fl-2 $_.name
- }
- pop-location
- }
-
- function fl-2()
- {
- push-location $args[0]
- $p = (get-item .).name
- $count = 0
- Get-ChildItem -Directory | foreach-object {
- $count += 1
- Rename-Item $_ -NewName ($p + $count.ToString().PadLeft(2,"0"))
- }
- Get-ChildItem -Directory | foreach-object {
- fl-3 $_.name
- }
- pop-location
- }
-
- function fl-3()
- {
- push-location $args[0]
- $p = (get-item .).name
- $count = 0
- Get-ChildItem -File "*.txt" | foreach-object {
- $count += 1
- Rename-Item $_ -NewName ($p + "-" + $count.ToString().PadLeft(2,"0") + $_.Extension)
- }
- pop-location
- }
-
-
- fl-1 "."
复制代码
|