shell - Create a "Recently Added Albums" m3u playlist -
i trying create playlist same idea "recently added albums" playlist see in itunes using $num_of_days_before parameter.
i've used ideas post: how recursively find , list latest modified files in directory subdirectories , times?
i've created script can run following params:
create_m3u /dir_root/with/mp3s 60
where $1 directory root of mp3s (that have folders within have mp3s) $2 number of days backwards today i'd create m3u playlist file.
the main part of script command:
find $1 -type f -iregex '.*\.mp3' -mtime -$2 -exec stat --format '%y %y %n' {} \; | \ sort -n | \ cut -d' ' -f5- | \ sed -e 's/^/\./'
now problem is, above command , including the
cut d' ' -f5-
part gives me type of output:
.... ./ratking - goes - 2014 [v0]/09. protein.mp3 ./ratking - goes - 2014 [v0]/08. puerto rican judo.mp3 ./ratking - goes - 2014 [v0]/02. canal.mp3 ./ratking - goes - 2014 [v0]/05. remove ya.mp3 ./ratking - goes - 2014 [v0]/04. sick stories.mp3 ./ratking - goes - 2014 [v0]/06. eat.mp3 ./ratking - goes - 2014 [v0]/03. snow beach.mp3 ./ratking - goes - 2014 [v0]/07. goes.mp3 ./ratking - goes - 2014 [v0]/01. _.mp3 ./ratking - goes - 2014 [v0]/10. bug fights.mp3 ./ratking - goes - 2014 [v0]/11. take.mp3 ./aesop rock - blob (2014) [mp3 320]/01 blob.mp3 ./the flaming lips - 7 skies h3 (2014) [v0]/06 - requiem.mp3 ./the flaming lips - 7 skies h3 (2014) [v0]/08 - riot in brain!!.mp3 ./the flaming lips - 7 skies h3 (2014) [v0]/10 - can't let go.mp3 ./the flaming lips - 7 skies h3 (2014) [v0]/03 - battling voices beyond.mp3 ./the flaming lips - 7 skies h3 (2014) [v0]/02 - meepy morp.mp3 ./the flaming lips - 7 skies h3 (2014) [v0]/07 - meepy morp (reprise).mp3 ./the flaming lips - 7 skies h3 (2014) [v0]/09 - 7 skies h3 (main theme).mp3 ./the flaming lips - 7 skies h3 (2014) [v0]/05 - metamorphosis.mp3 ./the flaming lips - 7 skies h3 (2014) [v0]/04 - in dream.mp3 ./the flaming lips - 7 skies h3 (2014) [v0]/01 - 7 skies h3 (can't shut off head).mp3 ./g. love & special sauce - 2014 - sugar/14 - bad girl baby blues.mp3 ./g. love & special sauce - 2014 - sugar/06 - sugar.mp3 ./g. love & special sauce - 2014 - sugar/10 - windshield wipers.mp3 ./g. love & special sauce - 2014 - sugar/02 - nite life.mp3 ./g. love & special sauce - 2014 - sugar/09 - 1 night romance.mp3 ./g. love & special sauce - 2014 - sugar/03 - life.mp3 ./g. love & special sauce - 2014 - sugar/04 - nothing else quite home.mp3 ./g. love & special sauce - 2014 - sugar/05 - smokin blues.mp3 ./g. love & special sauce - 2014 - sugar/08 - saturday night.mp3 ./g. love & special sauce - 2014 - sugar/13 - run me.mp3 ./g. love & special sauce - 2014 - sugar/07 - weekend dance #2.mp3 ./g. love & special sauce - 2014 - sugar/12 - month.mp3 ./g. love & special sauce - 2014 - sugar/01 - come man.mp3 ./g. love & special sauce - 2014 - sugar/11 - cheating heart.mp3
which way want (partially) - sorted date when album added filesystem/pc. additionally want have each album sorted song number 01, 02, 03, 04... each folder/album , not unordered numbers seen above.
does have advice on how can differently can desired result?
your original command has redundancies - question linked requires date in output, whereas don't, can skip of fields being outputted stat
. can skip stat
using find -printf
. should work (partly untested, sorry):
find $1 -type f -iregex '.*\.mp3' -mtime -$2 --printf "%t@~.%h~%f\n" |\ sort -t~ -nk1 -nk3 |\ cut -d~ -f2- |\ tr '~' '/'
the find
finds same files, prints out in following format:
[modified date in seconds since unix epoch]~.[file directory]~[filename] ex: 1234512345~./ratking - goes - 2014 [v0]~09. protein.mp3
we sort firstly date, , secondly filename (both numerically, , using ~
field separator). strip off date field, replace remaining ~
forward slash give full file path.
note: work if files have track number @ beginning of filename, , not give correct results file ~
anywhere in file path (directory or filename). not chosen special reason, can replace more suitable character if necessary. character replacement required (as opposed using forward slash sort delimiter) (i assume!) level of subdirectory each file in potentially vary.
Comments
Post a Comment