zsh-users
 help / color / mirror / code / Atom feed
* Renaming music files
@ 2014-05-25 12:26 meino.cramer
  2014-05-25 18:31 ` Peter Stephenson
  2014-05-25 18:59 ` Thomas Mitterfellner
  0 siblings, 2 replies; 3+ messages in thread
From: meino.cramer @ 2014-05-25 12:26 UTC (permalink / raw)
  To: zsh-users

Hi,

I often download music from http://freefloatingmusic.bandcamp.com/...
With a Sansa Clip ZIP I listen to the files.
This player has a OLED display of 96x96 pixel, which is only
a little bit smaller than Full HD...  ;)

The files inside of the arives are named like the following
pattern (names fictional and only as an example):

Gentoo/Gentoo - Sound of a UNIX System/Gentoo - Sound of a UNIX System - 01 Eternal Boot.flac
Gentoo/Gentoo - Sound of a UNIX System/Gentoo - Sound of a UNIX System - 02 Devine UDEV.flac
Gentoo/Gentoo - Sound of a UNIX System/Gentoo - Sound of a UNIX System - 03 Nvidias Light.flac

and so on...

Often spaces and '_'s and '-'s are mixed in no predictive order (NO
CRITISM indendat!)

The files are tagged, therefore the information given with the
filenames are also included in the tags inside the files themselves.

To save space on the display I use to rename the directories and files
to this (using zmv):

Gentoo/Sound of a UNIX System/01 Eternal Boot.flac
Gentoo/Sound of a UNIX System/02 Devine UDEV.flac
Gentoo/Sound of a UNIX System/03 Nvidias Light.flac

and use detox afterwards to get rid of the spaces in names.

Is there any way to automate this by instruct zmv to throw away
anything, which does not change and only keep the changing part?

Thank you very much in advance for any idea/help!
Best regards,
mcc













^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Renaming music files
  2014-05-25 12:26 Renaming music files meino.cramer
@ 2014-05-25 18:31 ` Peter Stephenson
  2014-05-25 18:59 ` Thomas Mitterfellner
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 2014-05-25 18:31 UTC (permalink / raw)
  To: zsh-users

On Sun, 25 May 2014 14:26:45 +0200
meino.cramer@gmx.de wrote:
> Gentoo/Gentoo - Sound of a UNIX System/Gentoo - Sound of a UNIX System - 01 Eternal Boot.flac
> Gentoo/Gentoo - Sound of a UNIX System/Gentoo - Sound of a UNIX System - 02 Devine UDEV.flac
> Gentoo/Gentoo - Sound of a UNIX System/Gentoo - Sound of a UNIX System - 03 Nvidias Light.flac
> 
> To save space on the display I use to rename the directories and files
> to this (using zmv):
> 
> Gentoo/Sound of a UNIX System/01 Eternal Boot.flac
> Gentoo/Sound of a UNIX System/02 Devine UDEV.flac
> Gentoo/Sound of a UNIX System/03 Nvidias Light.flac
> 
> and use detox afterwards to get rid of the spaces in names.
> 
> Is there any way to automate this by instruct zmv to throw away
> anything, which does not change and only keep the changing part?

Not using zmv, and not to automate *anything* that doesn't change ---
that's way too general for a computer to understand, unless you're
prepared to wait a few decades.  You'll end up removing repeated
letters, for example, or odd words that happen to occur in different
parts of the name.

However, in the form you've shown above you can do something like the
following.  Comment out the print and uncomment the mv.  You can make it
more general, but you'll have to find out any other ways significant
repetitions can occur, and any other ways the repeated segments can be
joined.


local seppat="[[:space:]]##[-_][[:space:]]##"
local seg f newf
local -A strip
local -a match mbegin mend

for f in **/*(.); do
  # Record bits we're going to strip
  strip=()
  newf=
  for seg in ${(s./.)f}; do
    # First see if there's anything we can strip.
    while [[ ${#strip} -ne 0 && $seg = (${(kj.|.)~strip})${~seppat}(#b)(*) ]]
    do
      seg=$match[1]
    done
    # Allow what's left to be stripped.
    strip[$seg]=1
    newf=${newf:+$newf/}$seg
  done
  if [[ $newf != $f ]]; then
    print "Would move from:\n$f\nto:\n$newf"
    # mv -- $f $newf
  fi
done


pws


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Renaming music files
  2014-05-25 12:26 Renaming music files meino.cramer
  2014-05-25 18:31 ` Peter Stephenson
@ 2014-05-25 18:59 ` Thomas Mitterfellner
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Mitterfellner @ 2014-05-25 18:59 UTC (permalink / raw)
  To: meino.cramer, zsh-users

Hi!

> Is there any way to automate this by instruct zmv to throw away
> anything, which does not change and only keep the changing part?

Not that it has anything to do with zsh, but did you have a look at
Easytag? I can rename your files in a flexible way according to the tag
information. Takes a little time/trial to discover its abilities but IMO
they're great! You can even do cddb lookups for albums you rip to flac
e.g. with cdparanoia, but I do digress…

Greetings,

Thomas


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-05-25 19:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-25 12:26 Renaming music files meino.cramer
2014-05-25 18:31 ` Peter Stephenson
2014-05-25 18:59 ` Thomas Mitterfellner

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).