dbr / tvnamer

Automatic TV episode file renamer, uses data from thetvdb.com via tvdb_api
https://pypi.python.org/pypi/tvnamer/
The Unlicense
907 stars 115 forks source link

Script not running on Windows #188

Closed ducklingere closed 3 years ago

ducklingere commented 3 years ago

Hi -

I'm incredibly new to python, and coding in general (my only experience is with Rainmeter). I'm trying to use this script and whenever I input something like the basic usages suggests ( tvnamer the.file.s01e01.avi) I'm met with the following message:

tvnamer : The term 'tvnamer' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + tvnamer Seinfeld.S01E01.The.Seinfeld.Chronicles.720p.WEBrip.AAC.EN-SU ... + ~~~~~~~ + CategoryInfo : ObjectNotFound: (tvnamer:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException

I've done my best to troubleshoot this with Google and the like, but I'm not sure what else there is for me to try.

I'm sorry if this isn't the right place for me to be asking for help, but again I'm new to this and wasn't sure where to go.

dbr commented 3 years ago

Hmm the main issue is the README instructions are only really tested on macOS and Linux in bash-like shells - Windows PowerShell will probably be slightly different

As far as I'm aware tvnamer should work fine on Windows, but I don't currently regularly test it, so I'm not sure exactly what you need to do

..but possibly try running tvnamer.exe? Alternatively 'python.exe -m tvnamer' should work if there is issues with the entry point command (i.e the thing which creates the 'tvnamer' command)

ducklingere commented 3 years ago

I've both installed tvnamer using pip and downloaded the code from here, and I'm not sure where to find the tvnamer executable. I've tried inputting the 'python.exe -m tvnamer' into windows command prompt as well as powershell (not sure if the two work differently or not) to no avail.

I'm quite appreciative of your help with this.

dbr commented 3 years ago

I tested this on Windows today and it seems to work as expected for me - the only thing which might be relevant was I checked the "Add to PATH" during the install (using the installer from www.python.org)

PS C:\Users\ben> pip install tvnamer
Collecting tvnamer
  Downloading tvnamer-3.0.tar.gz (47 kB)
[...]
PS C:\Users\ben> tvnamer
Usage: tvnamer [options] <files>

tvnamer: error: No filenames or directories supplied
PS C:\Users\ben> Get-Command tvnamer

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     tvnamer.exe                                        0.0.0.0    C:\Users\ben\AppData\Local\Programs\Python\Python38-32\Scripts\tvnamer.exe

I'm not sure if that option makes any difference, as I assume the Scripts folder gets added to Path regardless

ducklingere commented 3 years ago

Reinstalling python and checking that box seems to have fixed the issue! For some reason my pc was running a windows store version of python, and that was likely leading to my problems, though it wouldn't have occurred to me that it was.

One quick question though, it seems to me that the script won't recognize file names or directories with spaces in them, is this just me or is it universal?

Thank you for taking the time to assist me with this, I greatly appreciate it :)

dbr commented 3 years ago

Glad it's all working! Does seem like the Windows Store python was the issue - https://stackoverflow.com/questions/57421669/question-about-pip-using-python-from-windows-store - that contains a solution, but using an alternate installer seems much simpler!

One quick question though, it seems to me that the script won't recognize file names or directories with spaces in them, is this just me or is it universal?

Arguments with spaces are a complication with most command-line tools, nothing to do with tvnamer specifically. Command line tools typically use spaces to separate arguments (like tvnamer file1.avi file2.avi). So if your filenames contain spaces then it treats tvnamer The Show s01e01.avi as three separate filenames, none of which exist thus the error you get.

The solution to that is to escape the spaces, which depends on your shell - generally putting the filename in quotes works, like tvnamer "The Show.s01e01.avi" "The Show.s01e02.avi" etc. I think if you drag-and-drop the file onto the shell it will usually do this automatically which is a good reference