Advertisement
Guest User

Untitled

a guest
Feb 13th, 2021
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.51 KB | None | 0 0
  1. @echo off
  2.  
  3. :: Fullpath current folder : %cd%
  4. :: Fullpath folder where the right click was made : %~f1
  5. :: Name of the folder where the right click was made : for %%f in ("%~f1") do set Name=%%~nxf
  6.  
  7. for %%f in ("%~f1") do set Name=%%~nxf
  8.  
  9. :: Step 1: Creating a temporary folder
  10. mkdir "%~f1-Temp"
  11.  
  12. :: Step 2: Creation of all nfo txt files in the temporary folder
  13. FOR /F "tokens=*" %%G IN ('dir "%~f1" /b *.mkv') DO (
  14.    call "C:\Users\me\Desktop\MediaInfo\MediaInfo.exe" "%~f1\%%G" > "%~f1-Temp\%%~nG.txt"
  15. )
  16.  
  17. :: Step 3: Filling in the final nfo
  18. setlocal enabledelayedexpansion
  19. set i=0
  20.  
  21. FOR /F "tokens=*" %%G IN ('dir "%~f1" /b *.mkv') DO (
  22.    IF !i! == 1 (
  23.      echo ------------------------------------------------------------------------------------------------------------------------------------ >> "%~f1-Temp\%Name%.txt"
  24.      echo. >> "%~f1-Temp\%Name%.txt"
  25.      echo. >> "%~f1-Temp\%Name%.txt"
  26.   )
  27.    cat "%~f1-Temp\%%~nG.txt" >> "%~f1-Temp\%Name%.txt"
  28.    set i=1
  29. )
  30. endlocal
  31.  
  32. :: Step 4: Removing the path
  33. setlocal
  34. set $source="%~f1-Temp\%Name%.txt"
  35. set $dest="%~f1-Temp\%Name%1.txt"
  36. set "search=%~f1\\"
  37.  
  38. for /f "delims=" %%a in ('powershell -c "(get-content '%$source%') | foreach-object {$_ -replace '(?<=Complete name\s+:\s+).+\\'} | set-content '%$dest%'"') do echo %%a
  39. endlocal
  40.  
  41. :: Step 5: Renaming the nfo and moving to the right place
  42. Ren "%~f1-Temp\%Name%1.txt" "%Name%.nfo"
  43. move "%~f1-Temp\%Name%.nfo" "%~f1"
  44.  
  45. :: Step 6: Deleting temporary files
  46. rmdir /s /q "%~f1-Temp"
  47.  
  48. pause
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement