VodBox/pyWinContext

Issues with Paths containing spaces

Closed this issue · 5 comments

If the path of the currently selected file contains any spaces, it cuts it off there. This could be fixed (I think, at least it did for me) by adding quotes around the %1 when saving the command string.

The command string is ran by Window's batch interpreter unchanged, and so commands must be written with that in mind, such as making sure paths are properly surrounded by quotation marks in the right places. I can not introduce the automatic addition of quotation marks since there are cases where you don't want them (such as when printing text). The solution is to simply be careful with how you handle and contain the path strings (much like you would with any language).

dxf commented

@VodBox I put quotes around the variables like this:

ffmpeg -i "%~n1".flv "%~n1.mp4"

Yet it still says ffmpeg can't find the first bit of the file name.

Also, how do I make it get the initial filetype automatically vs it being static?

@dxf The command you are looking for is...

ffmpeg -i "%~1" "%~n1.mp4"

The issue was that the quotation marks needed to be around the whole name, not just the bit with the variable (so "%~n1.flv" would have worked).

But simpler than that, the n in %~n1 is interpreted by Windows to mean you want the file name without the file extension, whereas %~1 is the whole name, including extension (more info on that and other parameters can be found here).

dxf commented

@VodBox Thanks, please also check open issues, for some reason pywincontext crashes when trying to save?

hey im having the same problem. dragging and dropping a file onto a bat file works as intended, but using the bat with pywincontext cuts off everything except the first part of the filename
script.bat:

@echo off
echo "%~1"
echo "%~dpn1.opus"
pause

drag and dropping:

"C:\Users\me\Desktop\First audio file.mp3"
"C:\Users\me\Desktop\First audio file.opus"
Press any key to continue . . .

pywincontext:

"First.opus"
"C:\Users\me\Desktop\First"
Press any key to continue . . .