S1mp3ls

From S1MP3 Wiki

Jump to: navigation, search
#!/bin/sh -ue
# http://wiki.s1mp3.org/S1mp3ls -- On GNU/Linux List S1MP3 files in the same
# native order as seen on the player's display.
# Copyright       : http://www.fsf.org/copyleft/gpl.html
# Author          : Dan Jacobson http://jidanni.org/
# Created On      : Mon Feb 11 11:11:49 2008
# Last Modified On: Sat Jul  3 17:23:25 2010
# Update Count    : 66
case $@ in
    -*|*\ *)echo "Usage: $0 [S1MP3_root_directory]" 1>&2; exit 1;;
    '');;
    *)cd "$1";;
esac
echo `basename $0` `basename $PWD` `LC_ALL=C date`
set -- `find -type d ! -empty`
for types in 'MP3 WMA OGG ASF' 'WAV ACT' #"MUSIC" and "VOICE" modes; all?
do  echo === $types ===
    for d #on player, sub directories are listed first, here we list them last,
    # as we open them all...
    do  for type in $types
	do find $d -maxdepth 1 -iname \*.$type -printf %f\\n
	done|perl -nwe '$l.=sprintf "%03d $_", $.;
        END{if($.){$_="'$d'"; s@^\./?@@; s@$@/@; print "$_\n$l"}}'
    done
    echo
done|sed 's/\.mp3$//i' #strip the most common one
#The above was all worked out via trial and error.
#Using File::Find, or reading ID3 tags would only add complexity.

#Preliminary investigation of a different player that presents all songs as
#a single flat list no matter how deep nested:
#find $1 -type f -printf '%f\n'|perl -nwe 'printf "%03d %s", $., $_;'
#But should divide voice vs. music
Personal tools
about this site
Advertisement