Bug 237834

Summary: organize files: when the year is not set in the tags it always sets it to 0
Product: [Applications] amarok Reporter: Vasilis Vasaitis <vvasaitis>
Component: Collections/LocalAssignee: Amarok Developers <amarok-bugs-dist>
Status: RESOLVED FIXED    
Severity: normal CC: matej, ralf-engels, unnamedrambler
Priority: NOR    
Version: 2.3.0.90   
Target Milestone: 2.3.2   
Platform: Debian testing   
OS: Linux   
Latest Commit: Version Fixed In: 2.3.2

Description Vasilis Vasaitis 2010-05-16 15:55:44 UTC
Version:           2.3.1beta1 (using KDE 4.4.3)
OS:                Linux
Installed from:    Debian testing/unstable Packages

I'm using the Organize Files dialog to move my music files around, and I've put {%year - } at some point in the file name pattern, so that if there isn't a year in the tags it won't appear in the path either. However this doesn't work, because if the tags don't have a year then the path is formed as if the year had been set to 0.
Comment 1 Casey Link 2010-05-29 21:46:32 UTC
Thanks for the report!

Fix coming soon.
Comment 2 Casey Link 2010-05-30 06:40:23 UTC
commit f69f3f947b02e5e105589eb1d41eb802de35f042
Author: Casey Link <unnamedrambler@gmail.com>
Date:   Sat May 29 14:44:36 2010 -0500

    When a track has no year, organize dialog should replace %year with an
    empty string, before it was replacing it with 0.
    BUG: 237834

diff --git a/ChangeLog b/ChangeLog
index e80a6a5..4534e99 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -25,6 +25,8 @@ VERSION 2.3.2-Beta 1
       Patch by Richard Longland <rlongland@hotmail.com>.
 
   BUGFIXES:
+    * Fixed organize dialog's handling of the year tag. If there is no year
+      then the %year token should be an empty string.(BR 237834)
     * The "Ignore 'The'" option in the organize files dialog is now case
       insensitive. (BR 237831)
     * Filenames with dots (.) and other special RegEx characters will now be
diff --git a/src/dialogs/OrganizeCollectionDialog.cpp b/src/dialogs/OrganizeCollectionDialog.cpp
index ffebbbb..ff2ddac 100644
--- a/src/dialogs/OrganizeCollectionDialog.cpp
+++ b/src/dialogs/OrganizeCollectionDialog.cpp
@@ -171,7 +171,10 @@ OrganizeCollectionDialog::buildDestination( const QString &format, const Meta::T
     args["folder"] = ui->folderCombo->currentText();
     args["title"] = cleanPath( track->prettyName() );
     args["composer"] = track->composer() ? cleanPath( track->composer()->prettyName() ) : QString();
-    args["year"] = track->year() ? cleanPath( track->year()->prettyName() ) : QString();
+
+    // if year == 0 then we don't want include it
+    QString year = track->year() ? cleanPath( track->year()->prettyName() ) : QString();
+    args["year"] = year.localeAwareCompare( "0" ) == 0 ? QString() : year;
     args["album"] = track->album() ? cleanPath( track->album()->prettyName() ) : QString();
 
     if( track->discNumber() )