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
-2
votes
1 answer

Losing data in Python 3.5 shutil.copyfile

I'm using shutil library. When I using : backuped = shutil.copyfile(file1, file2) file2 is empty. There is not any problem with shutil.move. How can I copy file without losing data?
TheNone
  • 5,684
  • 13
  • 57
  • 98
-2
votes
2 answers

merge child directory into parent directory structure python

I have this directory structure... └── 01048 └── 2014 └── IN I want to merge this directory structure... └── 01048 └── 2014 └── AR └── AB To make this directory structure... └── 01048 └── 2014 └── IN …
Sam Luther
  • 1,170
  • 3
  • 18
  • 38
-2
votes
1 answer

find largest file in each sub directory and move files to a new directory

I am very new to python and stack overflow. In a directory, I have a list of many sub directories with many files within each. I am trying to figure out a way to find the largest file within each sub directory, and copy (move) these files to a new…
cali9er
  • 17
-2
votes
1 answer

How do you perform replacement of text in files and paste the replaced text at a specific position in one file

""" I am using this program to perform replamcement of text in four different files and then compare this to a tepmplate and then paste the replaced text at specific position in a single file.Create a new file from four different…
HEMS
  • 187
  • 1
  • 5
  • 17
-2
votes
1 answer

Sending email in python, message missing

I am deleting several folders which are 30 days old and want to mail myself the list of all those deleted folders using gmail. Currently it deletes the folder without any trouble but the message in the email is blank along with subject. What am I…
Quick Silver
  • 435
  • 2
  • 8
  • 17
-3
votes
1 answer

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

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 files (it's a project, I know stuff like 7Zip exists lol), and I am…
WhatTheClown
  • 464
  • 1
  • 7
  • 24
-3
votes
1 answer

Creating ZIP folder with shutil - Python

I'm trying to use shutil.make_archive but it's duplicating the folder name. Let me explain better: My folder R360 to be ziped is located at: C:\Users\PycharmProjects\Project\media\SAE\R360\ What I am trying to do is: create a zip folder with this…
Felipe Dourado
  • 441
  • 2
  • 12
-3
votes
2 answers

Python shutil module move exception handling

Destination path /tmp/abc in both Process 1 & Process 2 Say there are N number of process running we need to retain the file generated by the latest one Process1 import shutil shutil.move(src_path, destination_path) Process 2 import…
Shankar
  • 846
  • 8
  • 24
-3
votes
2 answers

Why I am not getting into the path file " the system cannot find the path specified "

So I am using a function in python which is being called in Robotframework to copy a file from a source to destination I have used os.path.join() and os.listdir() and os.path.normpath() to get access to the folder and copy using shutil But…
Raja_Viki
  • 13
  • 2
-3
votes
2 answers

Python script to copy n files to another folder

I'm looking for a python script that would took for example first 5000 files and copy them to another folder. Then after another run, it would took next 5000 files and copy them. I tried using shutil but couldn't make it work, no matter what I…
1 2 3
78
79