shutil

FileNotFound error when renaming files using shutil.move in Python

FileNotFound error when renaming files using shutil.move in Python Question: I’m in chapter 10 of Automate the Boring Stuff, and one of its activities suggests renaming files in order when one is missing (e.g., Spam001.txt, Spam002.txt, Spam004.txt, …). When testing the code with a print() call and commenting out the shutil.move(), the program does what …

Total answers: 1

Python program to rename files doesn't work on files on external drives

Python program to rename files doesn't work on files on external drives Question: I wrote this program to rename all files in a directory to title case, and it works fine on files on the system. But when I use it to rename files on an external drive, the program executes successfully without any exceptions …

Total answers: 1

python shutil.move getting .filepart on my filename

python shutil.move getting .filepart on my filename Question: im upload a file to api with the following code files=[ (‘nzb_file’,(nzbTitle,open(event.src_path,’rb’),’application/octet-stream’)) ] headers = {} response = requests.request("POST", url, headers=headers, data=payload, files=files) if response = 200 I want to move the file to DIR succes if response contains something else. I want the file moved to …

Total answers: 1

shutil.move() not working after reading object with pywin32

shutil.move() not working after reading object with pywin32 Question: I’ve got a script that is intended to sort my photo/video collection (Windows). The photos work fine as they are sortable by EXIF which is easily accessed. Videos are harder because I have to get the file’s "Media Creation Date" which is readable by only pywin32, …

Total answers: 1

Reading binary file using numpy in Streamlit

Reading binary file using numpy in Streamlit Question: I have the following code snippet that works perfectly well in python, however, I am trying to use streamlit to upload the binary files, but I can’t seem to make it work. Here is the working code in python: def read_bin(): dt = np.dtype([(‘col1′,’d’),(‘col2′,’d’),(‘col3′,’d’),(‘col4′,’d’)]) data = np.fromfile(‘Files/Bin …

Total answers: 1

How can i change file name while copying them using shutil?

How can i change file name while copying them using shutil? Question: I am using shutil to copy my files to another destination directory , what i want to achieve is src/red.png src/blue.png src/green.png for example if i select blue and green then while saving i want them to be saved as dst/blue_1001.png dst/green_1002.png Thanks …

Total answers: 2

Move file using specific nav path to another folder

Move file using specific nav path to another folder Question: I have a list of navigation paths to specific files, which all come from different folders. I’d like to move them all to a new folder. Specifically, my data is formatted in two columns in a dataframe, where I’d like to move each file to …

Total answers: 1

Is there a faster way to compress files/make an archive in Python?

Is there a faster way to compress files/make an archive in Python? Question: I’m making archive of a folder that has around ~1 GB of files in it. It takes like 1 or 2 minutes but I want it to be faster. I am making a UI app in Python that allows you to ZIP …

Total answers: 1

python shutil.move not working when moving from C to C but D to C

python shutil.move not working when moving from C to C but D to C Question: I am working on a simple installer for a app but I am getting errors. Code looks like: import shutil import os name = os.getlogin() source_path = os.path.abspath(‘foo.bar’) destination_path = os.path.join(‘C:’, ‘Users’, name, ‘AppData’, ‘Roaming’, ‘Microsoft’, ‘Windows’, ‘Start Menu’, ‘Programs’, …

Total answers: 1