Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $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 -path $torrentfile -Destination $datePath
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement