File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ getopts " :v" OPTION
4
+
5
+ while read -r FILE; do
6
+ DIR=" "
7
+
8
+ case " $FILE " in
9
+ * .jpg|* .jpeg|* .png) DIR=" images" ;;
10
+ * .doc|* .docx|* .txt|* .pdf) DIR=" documents" ;;
11
+ * .xls|* .xlsx|* .csv) DIR=" spreadsheets" ;;
12
+ * .sh) DIR=" scripts" ;;
13
+ * .zip|* .tar.gz|* .tar.bz2|* .tar) DIR=" archives" ;;
14
+ * .ppt|* .pptx) DIR=" presentations" ;;
15
+ * .mp3) DIR=" audio" ;;
16
+ * .mp4) DIR=" video" ;;
17
+ \? );;
18
+ esac
19
+
20
+ if [ -n " $DIR " ] && [ -f $FILE ]; then
21
+ [ -d " $DIR " ] || mkdir " $DIR "
22
+
23
+
24
+ if [ " ${OPTION} " = ' v' ]; then
25
+ echo " Move $FILE to $DIR "
26
+ fi
27
+
28
+ mv " $FILE " " $DIR "
29
+ fi
30
+ done < <( ls)
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ touch {1..10}.jpg {1..10}.png {1..10}.doc {1..10}.docx {1..10}.pdf {1..10}.csv {1..10}.sh {1..10}.tar.bz2 {1..10}.pptx {1..10}.mp3 {1..10}.mp4 {1..10}.unknown
You can’t perform that action at this time.
0 commit comments