Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- :: Fullpath current folder : %cd%
- :: Fullpath folder where the right click was made : %~f1
- :: Name of the folder where the right click was made : for %%f in ("%~f1") do set Name=%%~nxf
- for %%f in ("%~f1") do set Name=%%~nxf
- :: Step 1: Creating a temporary folder
- mkdir "%~f1-Temp"
- :: Step 2: Creation of all nfo txt files in the temporary folder
- FOR /F "tokens=*" %%G IN ('dir "%~f1" /b *.mkv') DO (
- call "C:\Users\me\Desktop\MediaInfo\MediaInfo.exe" "%~f1\%%G" > "%~f1-Temp\%%~nG.txt"
- )
- :: Step 3: Filling in the final nfo
- setlocal enabledelayedexpansion
- set i=0
- FOR /F "tokens=*" %%G IN ('dir "%~f1" /b *.mkv') DO (
- IF !i! == 1 (
- echo ------------------------------------------------------------------------------------------------------------------------------------ >> "%~f1-Temp\%Name%.txt"
- echo. >> "%~f1-Temp\%Name%.txt"
- echo. >> "%~f1-Temp\%Name%.txt"
- )
- cat "%~f1-Temp\%%~nG.txt" >> "%~f1-Temp\%Name%.txt"
- set i=1
- )
- endlocal
- :: Step 4: Removing the path
- setlocal
- set $source="%~f1-Temp\%Name%.txt"
- set $dest="%~f1-Temp\%Name%1.txt"
- set "search=%~f1\\"
- for /f "delims=" %%a in ('powershell -c "(get-content '%$source%') | foreach-object {$_ -replace '(?<=Complete name\s+:\s+).+\\'} | set-content '%$dest%'"') do echo %%a
- endlocal
- :: Step 5: Renaming the nfo and moving to the right place
- Ren "%~f1-Temp\%Name%1.txt" "%Name%.nfo"
- move "%~f1-Temp\%Name%.nfo" "%~f1"
- :: Step 6: Deleting temporary files
- rmdir /s /q "%~f1-Temp"
- pause
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement