Python Forum
What script to paste folders
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What script to paste folders
#1
Hello,

I'm new with python.
For my work i have to handle many files and folders.

I'm looking for a script which can copy a subfolder and past it in many other folders.

Is ti possible please ?
Reply
#2
If you use Linux, no need to bother with Python. You can use the commands below in a bash terminal, or make a bash script to do this.

You need to know what you want to copy and where you want to copy it to!

the -r flag stands for recursive, then cp will copy the directory and the contents to the destination.

Quote:# copy a file to 2 different folders the format is: echo destination1 destination2 | xargs -n 1 cp /path/to/sourcefile.something
echo /home/pedro/tmp/ /home/pedro/uploads/ | xargs -n 1 cp -v /home/pedro/temp/b.txt

Quote:# copy a whole directory to another directory the format is: cp -rv source destination
cp -rv /home/pedro/temp/ /home/pedro/tmp/

Quote:# copy a directory to 2 different directories the format is: echo /path1/ /path2/ /path3/ | xargs -n 1 cp -rv /path/to/directory/
echo /home/pedro/tmp/ /home/pedro/uploads/ | xargs -n 1 cp -rv /home/pedro/temp/

Fast and easy!

If you use Windows, you can probably do this in a similar fashion, but I don't know how!

To do this using Python, probably best to use the module shutil
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Please help me [copy and paste file from src to dst] midomarc 2 1,027 Nov-24-2022, 10:13 PM
Last Post: midomarc
  ImageTk Paste KDog 14 6,975 Jun-27-2021, 11:07 AM
Last Post: KDog
  Cut and Paste Oshadha 3 2,449 Jan-20-2021, 04:27 PM
Last Post: spaceraiders
  sub-folders in folders from text line jenost 1 1,579 Mar-31-2020, 07:16 AM
Last Post: ndc85430
  Python script that recursively zips folders WITHOUT nesting the folder inside the zip umkc1 1 2,858 Feb-11-2020, 09:12 PM
Last Post: michael1789
  Python Script to repeat Photoshop action in folders and subfolders silfer 2 4,568 Jul-25-2019, 03:12 PM
Last Post: silfer
  copy paste file and re-name it asheru93 1 2,386 May-24-2019, 10:43 AM
Last Post: heiner55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020