-
Notifications
You must be signed in to change notification settings - Fork 0
/
YN2.sh
executable file
·52 lines (41 loc) · 1.28 KB
/
YN2.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
#!/bin/bash
### VAR Section
bold=$(tput bold)
normal=$(tput sgr0)
### Functions
### Basic Script
clear
echo -e "\tThis script renames a group of files. Pleas use with care."
read -p "$bold Where are the files located?: $normal" "FL"
echo -e "\n$bold These are the files located at:$normal $(cd $FL;pwd)\n$(ls $FL)\n"
cd $FL
read -p "$bold Please input what you want to changed: $normal" remove
echo -e "\n\t$bold These are the files that will be changed $normal"
ls |grep "$remove"
read -p "$bold Please input what you want to add: $normal" add
ls | while read line
do mv "$line" "$(echo -e "$line" |sed -e "s/$remove/$add/" )" 2>/dev/null
done
echo -e "\n\t$bold The files have been renamed to:$normal"
ls |grep "$add"
### chice section
echo " "
read -p "Is this a good question (y/n)? " answer
case ${answer:0:1} in
y|Y )
echo "ok then"
echo -e "$FL"
read -p "$bold Please input what you want to changed: $normal" remove
echo -e "\n\t$bold These are the files that will be changed $normal"
ls |grep "$remove"
read -p "$bold Please input what you want to add: $normal" add
ls | while read line
do mv "$line" "$(echo -e "$line" |sed -e "s/$remove/$add/" )" 2>/dev/null
done
echo -e "\n\t$bold The files have been renamed to:$normal"
ls |grep "$add"
;;
* )
exit 0
;;
esac