Python Forum
Case sensitive path - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Case sensitive path (/thread-15702.html)



Case sensitive path - asheru93 - Jan-28-2019

Hello,

I want to open and setup.exe from python but sometimes it might be with uppercase like Setup.exe. How can I handle it properly?

I have:

myAppLowercase = path\setup.exe
myAppUppercase = path\Setup.exe


RE: Case sensitive path - Larz60+ - Jan-28-2019

what is path/setup.exe?
this code can't possibly work as posted.
please explain in more detail what you are trying to do.


RE: Case sensitive path - asheru93 - Jan-28-2019

Sorry for missing some important information.
So i want to install an specific app from a python script using this:

os.system('path_to_setup.exe')

This script will be executed on different machines. The app I want to install has multiple versions and for some of them the kit is with uppercase (Setup.exe) and for some of them with lowercase(setup.exe). I have a variable that has the path with lowercase for now:

myInstallPath = path\setup.exe

What I want is to be able to execute, os.system(myInstallPath) no matter if the kit installer is with uppercase or with lowercase.

Thank you


RE: Case sensitive path - mlieqo - Jan-28-2019

If there are only two possibilities, you can check if the first one exists otherwise use the second path:
my_install_path = 'my_path/setup.exe' if os.path.exists('my_path/setup.exe') else 'my_path/Setup.exe'



RE: Case sensitive path - buran - Jan-28-2019

the path is not case-sensitive on Windows, so it shouldn't matter


RE: Case sensitive path - snippsat - Jan-28-2019

Also should not be using os.system() it's deprecated and replaced by the subprocess module.
As mention bye @buran so is path/file name not case-sensitive.
import subprocess

subprocess.run(['python', 'version.py'])
So if i have VeRsiOn.py as filename it make no difference it run fine.


RE: Case sensitive path - asheru93 - Jan-28-2019

Thank you for your responses.