-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorganizm.sh
More file actions
55 lines (40 loc) · 1.35 KB
/
organizm.sh
File metadata and controls
55 lines (40 loc) · 1.35 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
if [ -d "$HOME/Downloads" ]; then
downloads_dir="$HOME/Downloads"
elif [ -d "$HOME/downloads" ]; then
downloads_dir="$HOME/downloads"
else
echo "Downloads folder not found, please read README"
exit 1
fi
if [ ! -r "$downloads_dir" ] || [ ! -w "$downloads_dir" ] || [ ! -x "$downloads_dir" ]; then
echo "You don't have full access to your Downloads folder"
exit 1
fi
cd "$downloads_dir"
mkdir -p "Images" "Videos" "Documents" "Archives" "Others"
for file in *; do
if [ ! -f "$file" ]; then
continue
fi
extension="${file##*.}"
extension=$(echo "$extension" | tr '[:upper:]' '[:lower:]')
case "$extension" in
jpg|jpeg|png|gif|bmp|webp|svg|ico|tiff|tif|heic|heif|raw|cr2|nef|psd|ai|eps|pnm)
mv -- "$file" Images/
;;
mp4|avi|mov|mkv|flv|wmv|webm|m4v|mpg|mpeg|mpv|m2v|3gp|ogv|vob|rm|rmvb|asf|mts|m2ts)
mv -- "$file" Videos/
;;
pdf|doc|docx|xls|xlsx|ppt|pptx|txt|rtf|odt|ods|odp|csv|tex|md|json|xml|yaml|yml|ini|cfg|conf|log|epub|mobi|azw)
mv -- "$file" Documents/
;;
zip|rar|7z|tar|gz|bz2|xz|tgz|tbz2|txz|z|lz|lzma|lzo|rz|sz|zoo|arj|cab|cpio|deb|rpm|pkg)
mv -- "$file" Archives/
;;
*)
mv -- "$file" Others/
;;
esac
done
echo "The organism has finished sorting"