summaryrefslogtreecommitdiffstats
path: root/.local/bin/sortunsorted
blob: 7691ca3f42799ded0d020e66e9abd0c3aba6b9c6 (plain) (blame)
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
#!/bin/bash

#Description: This program takes a paramater for the amount of videos you would like to sort from your UNSORTEDIR. If you do not pass a paramater, it will assume that you only wish to sort one video. These videos are then moved to ~/Videos/ with a new name that you provide or deleted depending on your choice.

#Axioms: UNSORTEDDIR

#Dependencies: https://packages.debian.org/sid/mpv

numofvids=1
playablevideo="$(find ~/Videos/unsorted/ -maxdepth 1 -type f | shuf | head -1)"

if [[ $# = 0 ]]
then
    if [[ "${playablevideo##*.}" == "png" || "${playablevideo##*.}" == "jpg" || "${playablevideo##*.}" == "jpeg" || "${playablevideo##*.}" == "webp" ]]
    then
        feh "$playablevideo"
    else
        mpv --ontop --geometry=50%:50% --autofit=50%x50% "$playablevideo"
    fi
    echo "Video played was: $playablevideo" 
    read -r -p "Was This quality? (y/n): " Choice
    if [ "$Choice" = 'y' ]
    then
        read -r -p "What would you like to name the video?: " Name
        touch "$playablevideo"
        if [[ "${playablevideo##*.}" == "gif" ]]
        then
            mv "$playablevideo" "/home/$USER/Pictures/gif/$Name.${playablevideo##*.}"
        elif [[ "${playablevideo##*.}" == "png" || "${playablevideo##*.}" == "jpg" || "${playablevideo##*.}" == "jpeg" || "${playablevideo##*.}" == "webp" ]]
        then
            mv "$playablevideo" "/home/$USER/Pictures/$Name.${playablevideo##*.}"
        else
            mv "$playablevideo" "/home/$USER/Videos/$Name.${playablevideo##*.}"
        fi

        exit
    elif [ "$Choice" = 'n' ]
    then
        rm "$playablevideo"
    else
        echo "You did nothing..."
    fi
    exit

fi

while [[ "$numofvids" -le "$1" ]]
do 
    if [[ "${playablevideo##*.}" == "png" || "${playablevideo##*.}" == "jpg" || "${playablevideo##*.}" == "jpeg" || "${playablevideo##*.}" == "webp" ]]
    then
        feh "$playablevideo"
    else
        mpv --ontop --geometry=50%:50% --autofit=50%x50% "$playablevideo"
    fi
    echo "Video played was: $playablevideo" 
    read -r -p "Was This quality? (y/n): " Choice
    if [ "$Choice" = 'y' ]
    then
        read -r -p "What would you like to name the video?: " Name
        touch "$playablevideo"
        if [[ "${playablevideo##*.}" == "gif" ]]
        then
            mv "$playablevideo" "/home/$USER/Pictures/gif/$Name.${playablevideo##*.}"
        elif [[ "${playablevideo##*.}" == "png" || "${playablevideo##*.}" == "jpg" || "${playablevideo##*.}" == "jpeg" || "${playablevideo##*.}" == "webp" ]]
        then
            mv "$playablevideo" "/home/$USER/Pictures/$Name.${playablevideo##*.}"
        else
            mv "$playablevideo" "/home/$USER/Videos/$Name.${playablevideo##*.}"
        fi
    elif [ "$Choice" = 'n' ]
    then
        rm "$playablevideo"
    else
        echo "You did nothing..."
    fi
    playablevideo="$(find ~/Videos/unsorted/ -maxdepth 1 -type f | shuf | head -1)"
    numofvids=$numofvids+1
done