aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mp3conv
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-02-23 14:56:51 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-02-23 14:56:51 +0530
commit78372b203a023ba8715b81e61fe19608627c916c (patch)
tree1bde8ca1cf294009e2388bd6b17abfb8c1530e31 /plugins/mp3conv
parent702e29bbe932809adaf047883568aa900f41c5c4 (diff)
downloadnnn-78372b203a023ba8715b81e61fe19608627c916c.tar.gz
Support coversion of current file
Diffstat (limited to 'plugins/mp3conv')
-rwxr-xr-xplugins/mp3conv25
1 files changed, 16 insertions, 9 deletions
diff --git a/plugins/mp3conv b/plugins/mp3conv
index b60b891..1c00909 100755
--- a/plugins/mp3conv
+++ b/plugins/mp3conv
@@ -9,10 +9,6 @@
outdir=_mp3files
-if ! [ -e "${outdir}" ]; then
- mkdir "${outdir}"
-fi
-
handle_multimedia() {
mime="${1}"
file="${2}"
@@ -26,9 +22,20 @@ handle_multimedia() {
esac
}
-for f in *; do
- if [ -f "${f}" ]; then
- mimestr="$( file --dereference --brief --mime-type -- "${f}" )"
- handle_multimedia "${mimestr}" "${f}"
+printf "Process 'a'll in directory or 'c'urrent? "
+read -r resp
+
+if [ "$resp" = "a" ]; then
+ if ! [ -e "${outdir}" ]; then
+ mkdir "${outdir}"
fi
-done
+
+ for f in *; do
+ if [ -f "${f}" ]; then
+ mimestr="$( file --dereference --brief --mime-type -- "${f}" )"
+ handle_multimedia "${mimestr}" "${f}"
+ fi
+ done
+elif [ "$resp" = "c" ] && [ -f "$1" ]; then
+ ffmpeg -i "${1}" -vn -codec:a libmp3lame -q:a 2 "${1%.*}.mp3"
+fi