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!

Trim Folder path to just folder name

Status
Not open for further replies.

d1trupinoy

Technical User
Dec 11, 2001
14
0
0
US
Newbie to python here. How do I trim the full path to a folder string to just the folder name

example - full path = "C:\\my test folder\myfolder"

desired string output = "myfolder"

Thanks for the help.
 
I figured it out.... use string.rfind to get the location of the last '\' then just slice the string.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top