Skip to content

Commit 8ae92a3

Browse files
authored
Update CLI_script_aria2c.sh
1 parent 3d6de75 commit 8ae92a3

File tree

1 file changed

+34
-7
lines changed

1 file changed

+34
-7
lines changed

CLI_script_aria2c.sh

+34-7
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,26 @@ echo ""
2121
unset options i
2222
while IFS= read -r -d $'\0' f; do
2323
options[i++]="$f"
24-
done < <(find ./ -maxdepth 1 -type f -name "*.txt" -print0 )
25-
if [ -z "${options[0]}" ]
26-
then
27-
echo -e "${RED}No valid .txt list found in current directory,${NC} exiting."
28-
exit
29-
fi
30-
select opt in "${options[@]}" "Quit"; do
24+
done < <( find ./ -maxdepth 1 -type f -name "*.txt" -print0 )
25+
#if [ -z "${options[0]}" ]
26+
#then
27+
# echo -e "${RED}No valid .txt list found in current directory,${NC} exiting."
28+
# exit
29+
#fi
30+
select opt in "${options[@]}" "Paste" "Quit"; do
3131
case $opt in
3232
*.txt)
3333
echo "$opt selected"
3434
break
3535
;;
36+
"Paste")
37+
printf "\n"
38+
read -d "@" -p "Paste links here (then press \"@\" when done) :
39+
" paste
40+
echo "$paste" > ./Paste
41+
printf "\n"
42+
break
43+
;;
3644
"Quit")
3745
#echo "You chose to stop"
3846
exit
@@ -43,6 +51,25 @@ select opt in "${options[@]}" "Quit"; do
4351
esac
4452
done
4553

54+
#CHECK IF FILE IS EMPTY
55+
if [ -f $opt ]
56+
then
57+
if ! [ -s $opt ]
58+
then
59+
echo "File exists but empty."
60+
exit
61+
fi
62+
count=$(wc -c < $opt)
63+
if [ $count -lt 4 ]
64+
then
65+
echo "File is empty."
66+
exit
67+
fi
68+
else
69+
echo "File not exists."
70+
exit
71+
fi
72+
4673
#ASKS DOWNLOAD DESTINATION
4774
read -e -p "Download Folder (enter or q to quit) : " targetdir
4875

0 commit comments

Comments
 (0)