JonnyJD / musicbrainz-isrcsubmit

script to submit ISRCs from disc to musicbrainz
http://jonnyjd.github.io/musicbrainz-isrcsubmit/
GNU General Public License v3.0
40 stars 13 forks source link

Run in same terminal #145

Open jesus2099 opened 1 year ago

jesus2099 commented 1 year ago

Summary

Patching the Windows-only isrcsubmit.bat file.

Without this patch

With this patch


I have a new PC with Windows 10 Pro and the isrcsubmit.bat command is unfortunately:

  1. Launching isrcsubmit.py in new window
  2. Closing this new window as soon as the script is ended
  3. Pausing the parent window with nothing visible (as the script was run in new window, now closed)

Running python <path>\isrcsubmit.py instead of isrcsubmit.py fixes this problem.

I also fix the problem that work variable cp is added to environment variables. I keep it local to the script, instead, with setlocal.


I have also added a code to pause the script only when launched from file explorer, with mouse, and not when launched from command line.

jesus2099 commented 1 year ago

https://github.com/JonnyJD/musicbrainz-isrcsubmit/assets/1401086/24b8ce18-f158-4ae6-934d-4107101cf24d

Here is what happens on my Windows 10 Professionnel 22H with Python 3.11.5.

First I run isrcsubmit_original.bat which is the original download. You cannot see the new CMD.exe terminal window that appears and disappear with no time to read the output. Then back on the original terminal with the pause message, for nothing.

Then I run my patched isrcsubmit.bat which displays output in same original terminal and that does not show useless pause message.

I will add a commit that enables a pause message, only when launching isrcsubmit.bat from mouse double-click, there it is needed.

jesus2099 commented 11 months ago

I have now added this code that will pause the script only when it is launched by mouse double-click (pause useful to see messages before terminal closes), and not when launched from CLI (pause useless):

echo %cmdcmdline%|findstr /c:"%~nx0" >nul
if %errorlevel% equ 0 echo.&pause
jesus2099 commented 9 months ago

Same on my new new office laptop:

Maybe it's only an issue in Windows Terminal, No I reproduce same problem with CMD.exe right now, but anyway the new code is great because then the script pauses appropriately when run from mouse double-click from File Explorer and does not pause when run from a command line.