0

So what I basically am trying to make is a program that asks user for file and displays absolute path of the program. For eg. If user enters 'Spotify' then I want to locate spotify.exe on the pc if It exists and print its absolute path.

I wanted to make this for a personal assistant that I am working on.

I previously tried

os.system(input + '.exe') but taking the eg of spotify only...it is not an internal file that will be recognised….please help.

temp123
  • 362
  • 1
  • 4

3 Answers3

1

You could use use os.walk to get the files's location and then os.path.abspath to get the full absolute pathname.

related answer: https://stackoverflow.com/a/1124841/2174832

matyas
  • 2,696
  • 23
  • 29
0

Have you tried

os.path.abspath(file)

Welyngton Dal Prá
  • 758
  • 1
  • 10
  • 19
-1

If you are using Linux, you can use os.system('which spotify')

Hyyudu
  • 134
  • 1
  • 7