Created
June 7, 2019 04:21
-
-
Save tr4nk/1da41c7ca4e353da4b39aff6afc9aa43 to your computer and use it in GitHub Desktop.
Copy file list from dir A to dir B/subdir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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