I have made a python script to upload new excel files from a folder on google drive. I would like to run this automatically via task scheduler. Unfortunately, running the file via task scheduler results in a different output, namely that the excel file can't be found.
I have done the following: I made a batch file of the python script and that one works fine. Then, I have put the filepath of the batch script under Actions>Program script in the task scheduler. It starts running the python script but can't find the excel files.
The batch file is in the same folder as the python files (which I run with pycharm), but the excel files the script is looking up is located on a (shared) google drive folder.
I have used this code to look up the excel files:
# check if file exists
try:
with open(currentfilepath) as f:
print("File exists: ", currentfilepath)
except FileNotFoundError:
print('File does not exist: ', currentfilepath)
So the problem is: if I run it in pycharm, the output says "File exists:", while when I run it in the task scheduler it gives the output "File does not exist:" Does anyone know why this happens and how I could solve it?