Bug 237834 - organize files: when the year is not set in the tags it always sets it to 0
Summary: organize files: when the year is not set in the tags it always sets it to 0
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: Collections/Local (show other bugs)
Version: 2.3.0.90
Platform: Debian testing Linux
: NOR normal
Target Milestone: 2.3.2
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-16 15:55 UTC by Vasilis Vasaitis
Modified: 2012-08-19 16:53 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 2.3.2


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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() )