0

I am working on a bot that downloads a file using python and selenium webdriver. I have successfully been able to design the bot and it is working perfectly. The issue is

  1. I want to target this file that was just downloaded. This program is going to be used by many people who may have set different directory for downloads. How do I use the OS module to achieve this?
  2. Once the data is downloaded from the site, the default name is transactions; my users may have other files with the same name and my program might copy a wrong file. The file is in an excel format.

How do I target this file alone and not any other file even if they have the same name or is there a way I can change the directory my bot save any file it downloads so I don't need to copy to the directory where I want it for calculations?

1 Answers1

0

consider use of shutil

newfilename = os.path.join(os.path.abspath('foopath'), 'foofile') shutil.copyfile('transactions', newfilename)

Reference other options at

copy-a-file-from-one-location-to-another-in-python

zerocog
  • 1,703
  • 21
  • 32
  • The will not be used by me only. All my downloads goes to downloads folder but my users might have it in another directory. How do i still get the file even if the user's download has changed? – Engr. Sule Muhammed Abba Mar 22 '22 at 11:59