-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathduplicateFF_KeepCopy
More file actions
40 lines (39 loc) · 1.17 KB
/
duplicateFF_KeepCopy
File metadata and controls
40 lines (39 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/bash
# $1 is the inputlist duplicate_FILES2_* (Note it must be _FILES2_)
# $2 is the destination directory
# This script moves all the files listed in the third column of $1 CSV file to $2 the destination directory.
if [ "$#" -ne 2 ]; then
echo "Please provide input_list and output_directory in that order "
exit 1
fi
in_list=$1
out_dir=$2
awk -F ',' '{ print $3}' $in_list | grepv "File"
echo
echo " Output directory : $out_dir"
echo
echo " If files and output directory are ok"
while true; do
read -p " Do you want to proceed? (y/n) " answer
case $answer in
y|Y) break;;
n|N) echo "Bye"; exit;;
* ) echo "Require y or n" ;;
esac
done
while true; do
read -p " Proceed with moving files? (y/n) " answer
case $answer in
y|Y) break;;
n|N) echo "Bye"; exit;;
* ) echo "Require y or n" ;;
esac
done
mkdir $out_dir 2>=1 /dev/null # no problems if already exists
if [ ! -d "$out_dir" ]; then
echo "$out_dir directory does not exist, creation failed"
exit
fi
echo "Moving files, may take a while"
awk -F ',' '{ print $3}' $in_list | grep -v "File"| xargs -I '{}' mv '{}' $out_dir
# all done