2016-09-09 228 views
1

我使用2個腳本通過文件夾內的年份torrent文件進行重新排版,但每個腳本都不完整,因爲我必須同時使用它們來移動它們。將文件夾移動到文件夾中移動

例如

1腳本

@Echo Off 
For %%a In (*19???.torrent *20???.torrent) Do Call :Sub "%%~a" 
Exit/B 
:Sub 
Set "mfn=%~n1" 
Set "lfc=%mfn:~-5% 
Set "lfc=%lfc:(= %" 
Set "lfc=%lfc:)= %" 
Set "lfc=%lfc: =%" 
If Not Exist "%lfc%\" MD %lfc% 
Move %1 %lfc% 

不要動文件,如(文件擴展名的.torrent)

Animali Pazzi (1939) Toto 
Anno 2000 La Corsa Della Morte 
American History X 1998 1080p ENG 
Devil 2010_001 

第二腳本

@Echo Off 
For /F "Tokens=*" %%a In (
    'Dir/B/A-D *.torrent^|Findstr/R "\<19[0-9][0-9]\> \<20[0-1][0-9]\>"') Do (
    For %%b In (%%~na) Do Call :Sub "%%a" "%%b") 
Pause 
Exit/B 
:Sub 
Set "mfn=%~2" 
Set "mfn=%mfn:(=%" 
If %mfn:)=% GEq 1900 (If %mfn:)=% Lss 2017 (If Not Exist "%mfn:)=%\" MD %mfn:)=% 
     Move %1 %mfn:)=%)) 

不移動文件,如

Alla 39 Eclisse - The Awakening 1980_001 
Predators 2010_002 
Sono il Numero Quattro.2011_001 
Abbronzatissimi.1991.avi 
Continuavano a chiamarlo trinita1971 x264 
32.Dicembre.1988.avi 

我想這兩個腳本,解決這個問題,移動的融合。

+0

您可以用[這](http://stackoverflow.com/a/39345515/2861476)試試。 –

+0

該解決方案正確創建文件夾,不會移動文件。我嘗試添加我的代碼,但出現錯誤 –

+0

它在答案中顯示。出於調試目的,'move'命令前綴有一個'echo'。如果輸出到控制檯是正確的,則移除'echo'離開'move'。 –

回答

1

我建議一個不同的腳本方法,如PowerShell的:

$ToFolder = "$env:USERPROFILE\Desktop\to" 
$FromFolder = "$env:USERPROFILE\Desktop\From" 

#Create the sample folder on your desktop 
#This line can be commented out if your ToFolder exists 
New-Item $ToFolder -ItemType directory -Force 

GCI -Path $FromFolder *.torrent | % { 
    if ($_.Name -match "(19|20)\d{2}") { 

     #Check to see if year folder already exists at the destination 
     #If not then create a folder based on this year 
     if (!(Test-Path "$ToFolder\$($Matches[0])")) { 
      New-Item -Path "$ToFolder\$($Matches[0])" -ItemType directory 
     } 

     #Transfer the matching file to its new folder 
     #Can be changed to Move-Item if happy with the results 
     Copy-Item -Path $_.FullName -Destination "$ToFolder\$($Matches[0])" -Force 
    } 
} 
+0

您的解決方案非常棒。我用'Move-Item'替換'Copy-Item' –

相關問題