Home > Software engineering >  Create a path with user inputs
Create a path with user inputs

Time:03-03

I'm trying to put together a path that works with user input:

a=input("Select a Path name to Navigate: ")
b=input("Select a second Path name to Navigate: ")
    subprocess.Popen((r'explorer /open,"\\Test\Test\Test\Test\Test\Test\a\Test\test\b\test"'))

But I'm trying to figure out how to do it. I either just get errors or it opens Windows Explorer without considering the path.

the path has 11 directories and 4 of them must be specified by the user via input

I'm really looking forward to your help for get this.

regards Sebastian

CodePudding user response:

This works on windows10:

import os
import subprocess

a=input("Select a Path name to Navigate: ")
b=input("Select a second Path name to Navigate: ")
path = os.path.join(a, b)

print('opening', path)

subprocess.Popen((f'explorer /open,{path}'))

In my case (windows10) a and b were c:\ and folder_name

You can extend this to as many folders as you like. path = os.path.join(a, b, c, d etc...)

  • Related