Py Script Won't Move File to Citrix Sharefile location

731
5
Jump to solution
01-27-2023 08:43 AM
JesseBaker
New Contributor

I have a simple script that exports and downloads a shapefile and stores it to my local desktop. I recently added these steps to simply move the file to a Citrix Sharefile location:

source = r'C:\temp\RAES Somerset Backups'
destination = r'S:\Shared Folders\........'
allfiles = os.listdir(source)
for f in allfiles:
shutil.move(os.path.join(source,f),destination)

When running the script in a Jupyter notebook, it works are expected. Though, when I try to schedule this through Task Scheduler on Windows 10, the file does not move to the shared location.

Any ideas???

0 Kudos
1 Solution

Accepted Solutions
RhettZufelt
MVP Frequent Contributor

Could be the S: drive mapping.  Drive mapping is user specific so the S: drive gets connected when you log in.  If you are running as Scheduled Task, often the same user is not logged in and the S: drive would not exist.

Try changing to UNC paths and see if that fixes the issue as that is independant of current logged in user.

R_

 

View solution in original post

0 Kudos
5 Replies
Clubdebambos
Occasional Contributor III

Hi @JesseBaker 

Ive had a similar issue in the past, it was nothing to do with my code, it was how I was setting up the Task Scheduler. Googled and tried a couple of things, but I cant remember what worked in the end. If you add in the workflow you are using for Task Scheduler it might help get some answers. Also, good practice not to have spaces in your filepaths if possible. Can sometimes cause weird behaviours with programming/programs.

~ learn.finaldraftmapping.com
0 Kudos
JesseBaker
New Contributor

@Clubdebambos  Appreciate the response! My trigger is just weekly on fridays when my user is signed in. Here is my action:

JesseBaker_0-1674839526856.png

I'm new to python but I'm lost as to why the entire script works up to the part where I want to move the file.

Any further advice is greatly appreciated!!

0 Kudos
Clubdebambos
Occasional Contributor III

Try the workflow in this link.

It uses a batch file. 

~ learn.finaldraftmapping.com
0 Kudos
JesseBaker
New Contributor

This helps as I can actually see the error that it is encountering, though I don't understand why it cannot find the file path. I tried wrapping the path in single and double quotes but get the same error either way.

Again, I am confused how it works in a jupyter notebook but not this way.

 

0 Kudos
RhettZufelt
MVP Frequent Contributor

Could be the S: drive mapping.  Drive mapping is user specific so the S: drive gets connected when you log in.  If you are running as Scheduled Task, often the same user is not logged in and the S: drive would not exist.

Try changing to UNC paths and see if that fixes the issue as that is independant of current logged in user.

R_

 

0 Kudos