bash - I'm trying to create a script that'll delete all files which have a bitrate less than 130 kbps -


to

#!/bin/bash find ./ -name '*.mp3' | while read -r i; echo "----------------------------------------"          if [ $(mp3info -x "$i" | grep audio | awk '{print $2}') < 130 ]                          read -p "delete?  " -n 1 -r                         if [[ $reply =~ ^[yy]$ ]]                                                 rm -f "$i" && echo "$i succesfully deleted!"                         fi         fi echo "----------------------------------------" done 

it stops output:

error opening mp3: /like prayer/madonna - act of contrition.mp3: no such file or directory 

it looks there error filepath, cause leading dot missing.

i think ifs set value ".". also, compare integers, use [[ ]]:

#!/bin/bash  find ./ -name '*.mp3' | while ifs='' read -r i;     echo "----------------------------------------"     if [[ $(mp3info -x "$i" | grep audio | awk '{print $2}') -lt 130 ]];         read -p "delete?  " -n 1 -r         if [[ $reply =~ ^[yy]$ ]];             rm -f "$i" && echo "$i succesfully deleted!"         fi     fi     echo "----------------------------------------" done 

btw think have add file question:

        read -p "delete $i? " -n 1 -r 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -