-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrename_remove.sh
88 lines (64 loc) · 2.03 KB
/
rename_remove.sh
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
#Script for renaming species in 1_data based on names_1_data_rename_seqs.csv
# Loading commandline data
while getopts r:d: flag
do
case "${flag}" in
r) rename_file=${OPTARG};;
d) remove_file=${OPTARG};;
esac
done
# Check if rename file is provided
if [ -z "$rename_file" ]; then
echo "Please provide a rename file using the -r option."
exit 1
fi
# Check if remove file is provided
if [ -z "$remove_file" ]; then
echo "Please provide a remove file using the -d option."
exit 1
fi
# Removing unnecessary files
rm *.xml *.csv
# Unpacking zip files
gunzip *gz
# Copying renaming list into folder
cp "$rename_file" .
# Renaming the files
cat "$rename_file" | while IFS=, read orig new; do mv "$orig" "$new"; done
# Removing the renaming list
rm "$rename_file"
# Removing hidden characters which were created by the renaming script
for f in *; do echo mv "$f" "$(sed 's/[^0-9A-Za-z_.]/_/g' <<< "$f")"; done
rename -n 's/(.*).{1}/$1/' *
# Removing files with bad clean in name
rm *.clean_*
# Removing files specified in the remove file
for f in $(cat "$remove_file")
do
rm "$f"
done
# Removing leftover shell scripts within data folder
rm *.sh
# #Removing unnecessary files
# rm *.xml *.csv
# #Unpacking zip files
# gunzip *gz
# #Copying renaming list into folder
# cp /home/owrisberg/Coryphoideae/github_code/coryphoideae_species_tree/names_1_data_1_rename_seqs.csv .
# #Renaming the files
# cat names_1_data_1_rename_seqs.csv | while IFS=, read orig new; do mv "$orig" "$new"; done
# #Removing the renaming list
# rm names_1_data_1_rename_seqs.csv
# #Removing hidden characters which were created by the renaming script
# for f in *; do echo mv "$f" "$(sed 's/[^0-9A-Za-z_.]/_/g' <<< "$f")"; done
# rename -n 's/(.*).{1}/$1/' *
# # Removing files with bad clean in name
# rm *.clean_*
# # Removing files with in names_1_data_2_rm_seqs.csv
# for f in $(cat /home/owrisberg/Coryphoideae/github_code/coryphoideae_species_tree/names_1_data_2_rm_seqs.csv)
# do
# rm "$f"
# done
# #Removing leftover shell scripts within datafolder
# rm *.sh