Skip to content

Instantly share code, notes, and snippets.

@tr4nk
Created June 7, 2019 04:21
Show Gist options
  • Save tr4nk/1da41c7ca4e353da4b39aff6afc9aa43 to your computer and use it in GitHub Desktop.
Save tr4nk/1da41c7ca4e353da4b39aff6afc9aa43 to your computer and use it in GitHub Desktop.
Copy file list from dir A to dir B/subdir
#!/bin/bash
# declare the following variables: SRC, DEST, LIST_FILE
# cmd: copy_file_list.sh "subdir"
SRC=/d/path/to/A
DEST=/d/path/to/B
# (subdir)
DEST_PARENT=$1
# file list using relative path
LIST_FILE=/d/Desktop/list.txt
cd $DEST
[[ -d $DEST_PARENT ]] || mkdir $DEST_PARENT
readarray LIST < $LIST_FILE
cd $SRC
for i in "${LIST[@]}"
do
cp --parents $i $DEST$DEST_PARENT
done
echo "DONE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment