I want to create a variable that's value is the name of the folder that I am working in. I can use pwd to see the working directory but I cannot figure out if there is a way to save the pwd output as a variable or better yet make a variable with only the current folder not the entire directory.
Asked
Active
Viewed 38 times
1 Answers
1
Here is one method:
#!/usr/bin/env python2.7
import os
current_folder = os.getcwd().split(os.sep)[-1]
print(current_folder)

Fake Code Monkey Rashid
- 13,731
- 6
- 37
- 41
-
That's perfect! Thank you! – Alison S Oct 11 '18 at 17:23