Trying to organize a shows *.nfo files so they have the same name as the mkv(Edit:avi woops doesn't really change code) they match.
Test Folder:
76107.2.1.nfo
76107.2.2.nfo
76107.2.3.nfo
Doctor Who - S02E01 (009) - Planet of Giants (1) - Planet of Giants.avi
Doctor Who - S02E01 (009) - Planet of Giants (2) - Dangerous Journey.avi
Doctor Who - S02E01 (009) - Planet of Giants (3) - Crisis.avi
Now the episode numbers in the 76107.2.*.nfo's are wrong in later folders the similarity in the test folder is only because it is the first of the season. so I can't simply compare names to match them up but they are in the right order so I'm trying to use counters to rename the first *.nfo the same as the first *.avi and then the second *.nfo the same as the second *.avi and so on!
I made a script I thought should work but it's doing nothing. Any help would be much appreciated! Edit It now works thanks to Aacini except for an odd bug noted under code.
@echo on
setlocal enableDelayedExpansion
set cnta=0
Set cntb=0
for %%b in (*.avi) do (
set /a cnta=cnta+1
set line_!cnta!=%%~Nb
)
for %%c in (*.nfo) do (
set /a cntb=cntb+1
for %%i in (!cntb!) do ren "%%~fc" "!line_%%i!.nfo"
)
Bug: The First nfo seems to get bumped to the end of the list but its place still kept. As in every other nfo is named to match its appropriate avi.
Test 1 (Original Test Folder) Results:
.nfo
Doctor Who - S02E01 (009) - Planet of Giants (1) - Planet of Giants.avi
Doctor Who - S02E01 (009) - Planet of Giants (2) - Dangerous Journey.avi
Doctor Who - S02E01 (009) - Planet of Giants (2) - Dangerous Journey.nfo
Doctor Who - S02E01 (009) - Planet of Giants (3) - Crisis.avi
Doctor Who - S02E01 (009) - Planet of Giants (3) - Crisis.nfo
Test 2 (Added Extra Bonus File) Results:
Doctor Who - S02E01 (009) - Planet of Giants (1) - Planet of Giants.avi
Doctor Who - S02E01 (009) - Planet of Giants (2) - Dangerous Journey.avi
Doctor Who - S02E01 (009) - Planet of Giants (2) - Dangerous Journey.nfo
Doctor Who - S02E01 (009) - Planet of Giants (3) - Crisis.avi
Doctor Who - S02E01 (009) - Planet of Giants (3) - Crisis.nfo
Doctor Who - S02E01 (009) - Planet of Giants (4) - The Making of Planet of Giants.avi
Doctor Who - S02E01 (009) - Planet of Giants (4) - The Making of Planet of Giants.nfo
Some folders will contain bonus videos at the end of the list that do not have matching nfo's but they are always at the end. I read the nfo's to verify only the ".nfo"(Test 1)/"Doctor Who - S02E01 (009) - Planet of Giants (4) - The Making of Planet of Giants.nfo"(Test 2) were misplaced they should of been "Doctor Who - S02E01 (009) - Planet of Giants (1) - Planet of Giants.nfo"