Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to open a folder in Python command after it was been created automatically?

Status
Not open for further replies.

Jongskie M.

Technical User
Dec 30, 2023
21
0
1
AE
Dear Gents,

Below script creates a previous folder based on the date.

1. The question is how to go or open that folder automatically after it was been created.
2. How to create two folders with different drive or path based on the script below.

path = "G:" "H:"
current_time = yesterday.strftime('%Y\%b %Y\%Y-%m-%d')
command = "mkdir {0}".format(current_time)
os.chdir(path)
os.system(command)
os.startfile(path) <== this only open the root folder not from the newly created one.

thanks.
 
Code:
[COLOR=#EF2929]path[/color] = "G:" "H:"
current_time = yesterday.strftime('%Y\%b %Y\%Y-%m-%d')
command = "mkdir {0}".format(current_time)
os.chdir(path)
os.system(command)
os.startfile([COLOR=#EF2929]path[/color]) <== this only open the root folder.

Of course.
 
You need to build a String or Path object for your newly created directory and pass that to os.startfile().
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top