I have a script in Python that works fine, it creates about 1000 files once the script is ran.
So I implemented some code to move the files to a new folder once the script is ran.
import glob, os, shutil
source_dir = 'C:/Users/george/Desktop/my aemo app/a'
dst = 'C:/Users/george/Desktop/my aemo app/b'
files = glob.iglob(os.path.join(source_dir, "*.csv"))
for file in files:
if os.path.isfile(file):
shutil.copy2(file, dst)
This works fine when I run it in idle, however once made executable and I send the program to someone else, it doesn't move the files for them?
I imagine the problem with sending to another user is that their username probably isn't "george" and therefore their file structure is different than what your program is looking for. I would try using environment variables or relative pathways to move files around on a program that is to be distributed. os documentation: https://docs.python.org/2/library/os.html#process-parameters
relative pathways would be something like ../../file/deepFile/whatYoureLookingFor
if you want to go up 2 directories from where you run the program and then dive down another path into file