Questions tagged [shutil]

A Python module which contains a number of utility methods for file or directory operations, such as copying, moving, etc.

The Python shutil module offers a number of high-level operations on files and collections of files. In particular, functions are provided which support file copying and removal.

Documentation: https://docs.python.org/3.2/library/shutil.html

1181 questions
-1
votes
1 answer

Python - Error when merging multiple files and then delete the source file

I am trying to merge a set of files from a folder into one file and then delete all the files apart from the merged file. I get an error shutil.SameFileError: '/Users/user/folder/.DS_Store' and '/Users/user/folder/.DS_Store' are the same file Given…
Kevin Nash
  • 1,511
  • 3
  • 18
  • 37
-1
votes
1 answer

How to copy one file into one folder accordingly?

I would like to make a program that can copy one file(e.g. images) to another directory which contains several folders. By just copying all the images to another directory is easy but I wanted it to be one image copies to one folder. I looped every…
-1
votes
1 answer

How do I find a file in a directory, from a CSV list, then move that file to another folder? Python

I have a csv file with Row 1 being the headers, column 1(A) is the file name I am looking for e.g. i_suck_at_python.xlsx and column 2(B) is the folder name I want to move it to e.g. Lex sucks at Python. I have done similar on Openpyxl, except I…
Lex Dunko
  • 13
  • 1
  • 6
-1
votes
1 answer

move files from child directories (from unzipping) to parent directory in unzip step?

I've got a specific problem: I am downloading some large sets of data using requests. Each request provides me with a compressed file, containing a manifest of the download, and folders, each containing 1 file. I can unzip the archive + remove…
MHeydt
  • 135
  • 8
-1
votes
1 answer

Python Xlrd to import .xslx Template, the use Openpyxl to Edit and Re-save .xslx File

I have an .xslx file with specific formatting and objects that I am using for reports that I plan on producing on a large scale using Python. I originally was openpyxl to load a copy of the template (openpyxl.load_workbook()), write a Pandas…
Abootman
  • 63
  • 1
  • 10
-1
votes
1 answer

Cannot get Python shutil.copytree ignore pattern to work

I am somewhat new to Python but not coding. I'm trying to get copytree to work, and it does, but it will not work with ignore_patterns. I think it's because I don't know how to send a variable list of files to the ignore_patterns() function. I tried…
-1
votes
1 answer

Issue with moving a file using shutil.move()

I am trying to move a file using the shutil module in Python. I keep getting this error: Traceback (most recent call last): File "", line 31, in File "C:\Python27\lib\shutil.py", line 302, in move copy2(src, real_dst) File…
Kyle K
  • 503
  • 1
  • 4
  • 9
-1
votes
1 answer

Python Automatically Back up Files to Google Drive

I am currently planning to automatically back up files to Google Drive like this: 1. Create a script to do the job: import glob, os, shutil src = r'/Users/me' dst = r'/Users/me/Google Drive/Code' files = glob.iglob(os.path.join(src, "*.ipynb")) for…
Dance Party
  • 3,459
  • 10
  • 42
  • 67
-1
votes
1 answer

Locating files by name for copying elsewhere

New to Python... I'm trying to have python take a text file of file names (new name on each row), and store them as strings ... i.e import os, shutil files_to_find = [] with open('C:\\pathtofile\\lostfiles.txt') as fh: for row in fh: …
Harley
  • 1
-1
votes
2 answers

How to resolve Errno 13 Permission Denied

I have researched the similarly asked questions without prevail. I am trying to os.walk() a file tree copying a set of files to each directory. Individual files seem to copy ok (1st iteration atleast), but an error is thrown (IOError: [Errno 13]…
Noah Huntington
  • 409
  • 2
  • 5
  • 17
-1
votes
1 answer

How to correctly move Files with Python

I already read some useful infos here about moving files with Python. But those are not working on my machine. I use eclipse to run python and the program should move files within windows. I used os.rename, shutil.move, shutil.copy and so…
-1
votes
4 answers

How do i copy files with shutil in python

im trying to copy a .txt file from one dest to another. This code is running but the file isnt copying. What am i doing wrong? import shutil import os src = "/c:/users/mick/temp" src2 = "c:/users/mick" dst = "/c:/users/mick/newfolder1/" for files…
Mick Burton
  • 1
  • 1
  • 2
-1
votes
1 answer

Moving certain files from subdirectories in Python

I have a large folder with lots of subfolders, each of which contains one to several files. I'd like to move some of these files based on their filename. I have a list containing the filenames of the files I want to move, so basically I would like…
Alice312
  • 13
  • 3
-2
votes
3 answers

Move files with a condition in Python

I need to move files from one folder to another based on a given condition. The condition is that if a certain file has more than or equal to 100 rows (for example), it will be moved to another folder. I've tried different versions of shutil…
solo1111
  • 11
  • 2
-2
votes
2 answers

How can I move files from a Mac to an external DD, without lost the tags?

In some case, tags are lost when I move files from a Mac to an external DD. (f is the file) If I use shutil.move("/Users/gilles/Desktop/" + f, "/Users/gilles/Douments/"), it's ok but if I use shutil.move("/Users/gilles/Desktop/" + f,…
Gilles57
  • 1
  • 1