JSFiddle - React, Tailwind, and code Playground

bash_script_regex_mid3v2_mutagen_trackNames.sh

by dledle2

JavaScript

#!/bin/bash

if [ $# -eq 0 ]; then
    echo " "
    echo "No arguments provided"
    echo " "
    echo "This script calls exiftool, and sets the ID3 tag for the"
    echo "track names matching *.mp3"
    echo "in the current folder equal to the first cmd line arg"
    echo "right after that argument with no spaces it will put the"
    echo " LAST FOUND NUMBER before the last dot in the filename"
    echo " "
    echo "you can change how zeros are padded onto the number by editing"
    echo "the number 2 in  -->  printf %02.0f  <--  in this script"
    echo " "
    echo "Example command line: "
    echo "   script.sh \"Harry Potter and the Sorcerer's Stone - Track \"  "
    echo " "
    exit 1
fi


#filename="aaaaaa..b.mp3"
#filename="asdasd.asdasd.asdasd.32423423.234234.dddd.aaaaaaa.b.mp3"
#filename_no_ext="$(echo $filename | rev | cut -f 2- -d '.' | rev)"
#echo $filename_no_ext

#read -n1 -r -p "Press space to continue..." key



###y=$(echo "44 the name here 243"|sed '/[^0-9]/g');
###echo $y

###!/bin/bash
FILES=*.mp3
for f in $FILES
do
  echo "Processing $f file..."

  filename_no_ext="$(echo $f | rev | cut -f 2- -d '.' | rev)"
  
  regex_perl_command="echo $filename_no_ext | perl -wnE'say for /[0-9]{1,99}$/g'"
  ##removed the space before the numbers and added a $ to mean end of the line 
  regex_match1="$(eval $regex_perl_command)"
          #echo $regex_match1
  found_track_number=$regex_match1
  padding_variable_max=10
  #10 means things like 07 08 09 10 11 12, also if over 100 like 101 102 works
  #padding_variable_max=100
  #padding_variable_max=1000
  #padding_variable_max=10000
  #padded_found_track_number="$(eval printf "%0*d" ${#padding_variable_max} $found_track_number     )"
  #padded_found_track_number="$(eval  printf %02d $found_track_number     )"
  ##above: Attention though if your input string has a leading zero!
  ##   printf will still do the padding, but also convert your string to 
  ##       hex/ octal format.
  #A solution to this seems...