Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Case sensitive path
#1
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
Reply
#2
what is path/setup.exe?
this code can't possibly work as posted.
please explain in more detail what you are trying to do.
Reply
#3
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
Reply
#4
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'
Reply
#5
the path is not case-sensitive on Windows, so it shouldn't matter
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#6
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.
Reply
#7
Thank you for your responses.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Context-sensitive delimiter ZZTurn 9 1,392 May-16-2023, 07:31 AM
Last Post: Gribouillis
  Switch case or match case? Frankduc 9 4,386 Jan-20-2022, 01:56 PM
Last Post: Frankduc
  WebDriverException: Message: 'PATH TO CHROME DRIVER' executable needs to be in PATH Led_Zeppelin 1 2,149 Sep-09-2021, 01:25 PM
Last Post: Yoriz
  Case sensitive checks kam_uk 2 1,968 Nov-30-2020, 01:25 AM
Last Post: bowlofred
  How do I copy files without case sensitive? mcesmcsc 8 4,851 Dec-18-2019, 02:19 PM
Last Post: mcesmcsc
  case-sensitive search saisankalpj 1 2,186 Jul-03-2018, 02:46 PM
Last Post: gruntfutuk
  .pth file does not show up in sys.path when configuring path. arjunsingh2908 2 5,669 Jul-03-2018, 11:16 AM
Last Post: arjunsingh2908

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020