0

Given a folder structure, such as:

/Parent-Folder
  /Child-Folder
    /Child-Child-Folder
  ...

How do I copy/paste all child folders to a list of destinations, such as:

Dest Folder/
Dest Folder2/
Dest Folder3/
2
  • What OS? What command interpreter? Jan 17, 2020 at 21:43
  • @music2myear Thanks - adjusted the title/tags.
    – Zollie
    Jan 18, 2020 at 22:31

1 Answer 1

1

This solution is a combination of two posts. One related to recursively moving folders and another related to generating a list of folders.

  1. Create a text file with all paths listed on separate lines. Each path should be in quotes to avoid special character errors. For example, destinations.txt could look like:
"Dest Folder/"
"Dest Folder2/"
"Dest Folder3/"
  1. Run the following in the terminal:
xargs -tI % cp -r "parent-folder/" % < destinations.txt

How it Works

xargs -tI % [command] % < [file]

This portion calls a command for each line in a file.

cp -r source/ dest/

This is the command being repeated. It recursively copies the contents of the source folder to a destination folder.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .