operating system - Python thinks file is still a .py when it is .exe -


got weird behavior here. using import os find path of exe file , use path in batch file move exe file. i've used pyinstaller make program exe.

now here issue occurs. os commands works well, thinks file still .py odd because made variable:

dirname = os.path.abspath(__file__) 

now, finds correct directory , correct file name(but not file type) use variable write down directory file in this:

move.write('move /y "' + str(dirname) + '" (code continues here, not important) 

this works when file .py not when .exe

i hope makes sense, feel free ask and/or edit if unclear.

current output: system cannot find file specified. wanted output: 1 file(s) moved.

you can specify extension want way:

files = os.listdir('/your/directory') filename in files:     if filename.endswith(".exe"):#or extension want         #copy file want 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -