这个骗局对我来说是个噩梦。
我尝试提取逐年文件列表,然后将.torrent文件移到相关文件夹中但不成功。
要创建文件夹,我尝试2个powershell脚本
创建文件夹
$movies = @()
(get-content C:\Path\Test4.txt) | foreach($_){
$properties = @{
date = $_.substring($_.IndexOf("(")+1,4)
name = $_.substring(0,$_.IndexOf("("))
}
$movies += New-Object PSObject -Property $properties
}
$movies
foreach($movie in $movies){
$movie.date
$datePath = "C:\Path\$($movie.date)"
if(-not(test-path $datePath)) {
new-item $datePath -ItemType "directory"
}
$words = $movie.name -split '\s'
$words
}
创建文件夹并尝试匹配
$movies = @()
(get-content C:\Path\Test4.txt) | foreach($_){
$properties = @{
date = $_.substring($_.IndexOf("(")+1,4)
name = $_.substring(0,$_.IndexOf("("))
}
write-host $date
write-host $name
$movies += New-Object PSObject -Property $properties
}
$torrentFiles = dir $torrentPath
foreach($movie in $movies){
$datePath = "C:\Path\$($movie.date)"
if(-not(test-path $datePath)) {
new-item $datePath -ItemType "directory"
}
$words = ($movie.name -split '\s') | ?{ $_.Length -gt 1}
$significant = $words.Count
foreach($torrentFile in $torrentFiles){
$matchingWords = 0
foreach($word in $words){
if($torrentFile.BaseName -match $word){
$matchingWords += 1
}
}
if($matchingWords -ge $significant){
$_ | Move-Item -Destination $datePath
}
}
}
错误:
System.ArgumentiException
Cannot bind argument to parameter 'Path' because it is null error
注意:第二个脚本永远不会停止!
我期待这个:
film stackoverflow.torrent
←文件名torrent C:\ Path
film stackoverflow (2006)
←文本字符串在 C:\ Path 的文件列表中
film stackoverflow.torrent
移入文件夹 2006