-1

I have directory '/batchjobs/files/'. I want to know the complete path of it.

4
  • 3
    I think this is what you are after: How to get an absolute file path in Python. Short answer: os.path.abspath('/batchjobs/files/') Commented Jul 28, 2022 at 15:05
  • @JNevill I am looking for directory complete path, not a file's. Commented Jul 28, 2022 at 15:18
  • If you check on that duplicate link you will find lots of options, which is why I linked it. Perhaps the very top answer that is showing: os.path.join( os.getcwd(), 'batchjobs/files/' ) would do the trick? There's likely lots of ways to solve this and most of them are listed out as optional answers there. Commented Jul 28, 2022 at 15:20
  • /batchjobs/files is already an absolute path -- / is the root directory. It would be a relative path if it was ./batchjobs/files or batchjobs/files Commented Jul 28, 2022 at 15:48

1 Answer 1

0

You can use the pathlib library.

import pathlib
print(pathlib.Path('/batchjobs/files/').absolute())
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the response @Dennis, but it returns /batchjobs only. I need to get the complete path of /batchjobs/files/. which will be something like /A/B/C/batchjobs/files/
actually i think the parent. part was unnecessary, just made an edit to my answer, try this one instead pls

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.