-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlatest.sh
47 lines (36 loc) · 1 KB
/
latest.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
#!/bin/bash
#this script find the latest .mp4 file and convert it to mp3 if if it have users approval
#FOLDER=`cat directory.txt`; #default directory ~/Music #TODO #DONE
FOLDER=~/Music
while :; do
cd $FOLDER;
find -maxdepth 1 -name '*.mp4' > temp; #find mp4s in default setted folder (sort by time)
FILE=`head -n 1 temp`; #save the first line (newest)
FILE=${FILE:2}; # cut ./ chars comming from find command
#FILE=`ls -t1 | head -n1`
if [ -s temp ]; then
zenity --question --text="Convert $FILE ?";
else
zenity --info --text="There is no mp4 file in this directory $FOLDER";
DIR=`zenity --file-selection --directory`;
if [ $? = 1 ]; then
exit;
fi
fi
if [ $? = 0 ]; then
ffmpeg -i "$FILE" "$FILE.mp3";
notify-send "$FILE converted";
exit;
else
zenity --info --text="Then..choose the directory you want";
if [ $? = 1 ]; then
exit;
fi
DIR=`zenity --file-selection --directory`;
if [ $? = 1 ]; then
exit;
fi
FOLDER=$DIR ;
fi
done
rm temp;