-2

How can I change directory every launch programm?

For example, I need to ask directory before programm running:

     a = input()
     06
     os.chdir("C:\\Test\\a.2020") > os.chdir("C:\\Test\\06.2020")

1 Answers1

0

You can pass the directory path as sys.argv while triggering the module.

    class FlatData:
        def __init__(self):
            # connection with elasticsearch at localhost
            self.es = elasticsearch.Elasticsearch([{'host': 'localhost', 'port': 9200}], http_auth=('XXXXX', 'XXXXX'), timeout=500)


        def activeCount(self, directoryPath):
            os.chdir(directoryPath)
            print("Current Working Directory ", os.getcwd())


    if __name__ == "__main__":
        fd = FlatData()
        fd.activeCount(sys.argv[1])
Ani Guner
  • 106
  • 3