【发布时间】:2017-07-04 17:55:28
【问题描述】:
谁能帮忙完成这个家庭项目?
我正在尝试对一个 500gb 以上的随机文件目录进行排序。
我想将这些文件分类到名为“A”、“B”、“C”...、“1”、“2”、“3”...的子目录中。
###################################################
# I've created a test directory to try my script against
###################################################
<# Start 7/4/2017 #>
Set-Location 'D:\IT Notes\psroot'
<# Make directories A..Z#>
65..90 | % {md ("{0}" -f [char]$_)}
<# Make a list of 0-9, A-Z, & a-z #>
$chars = [char[]] ([char]'0'..[char]'9' + [char]'A'..[char]'Z' + [char]'a'..[char]'z')
<# Use chars list to create random.txt file#>
(1..100).ForEach({-join (Get-Random $chars -Count 10) | Add-Content random.txt })
<# Save random.txt list to a variable#>
$random = (Get-Content .\random.txt)
<# Create files & add .txt extension #>
New-Item $random -ItemType file | Rename-Item -NewName {$_.name + ".txt"}
###################################################
现在我如何将所有内容分类到他们尊重的目录中?
提前感谢您的帮助!
【问题讨论】:
-
Soo,所有代码都与您的问题无关,您的问题是“为我写这个脚本?” - 离题,太宽泛,或对没有研究工作投反对票,或其他什么。 stackoverflow.com/q/38485877/478656 和 stackoverflow.com/q/21117208/478656 和 stackoverflow.com/q/41467996/478656 和 stackoverflow.com/q/11777466/478656 和 stackoverflow.com/q/7316797/478656 和 stackoverflow.com/q/30727325/478656 和 stackoverflow.com/q/37617391/478656 或多或少都是同一个问题,应该让你有很多方法。跨度>
标签: powershell filesystems powershell-4.0