Bottom Page

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
Quote
#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.
Quote
#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
Quote
#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'
asheru93 likes this post
Quote
#5
the path is not case-sensitive on Windows, so it shouldn't matter
asheru93 likes this post
Quote
#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.
Quote
#7
Thank you for your responses.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  how do i write a cross-platform relative file path? pseudo 2 36 2 hours ago
Last Post: ThomasL
  How do I set the path to my module one directory below my python 3.7.3 program? deac33 1 75 Jul-30-2019, 04:13 AM
Last Post: Larz60+
  File Path not recognised starzar 3 162 Jul-27-2019, 05:23 AM
Last Post: starzar
  FileNotFoundError...System cannot find the path specified alex9745 28 3,589 Jul-23-2019, 05:14 AM
Last Post: alex9745
  Help | How to make Dynamic Path/Address soothsayerpg 3 188 Jul-14-2019, 03:51 PM
Last Post: DeaD_EyE
  ImportError: cannot import name 'path' user123 2 244 Jul-14-2019, 10:08 AM
Last Post: Larz60+
  Writing the Path to a file properly dcw9996 2 201 Jul-01-2019, 11:26 PM
Last Post: dcw9996
  Help with environment path variables kuharido 0 183 Jun-07-2019, 09:18 PM
Last Post: kuharido
  sys.path miss dist-packages in a virtual env. chomwitt 2 178 May-23-2019, 08:08 PM
Last Post: chomwitt
  Retrieve protocol in lower case Variables 1 188 May-02-2019, 04:46 AM
Last Post: Larz60+

Forum Jump:


Users browsing this thread: 1 Guest(s)