diff --git a/src/organize/organize.cpp b/src/organize/organize.cpp index 73ac6a381..e72db7cbe 100644 --- a/src/organize/organize.cpp +++ b/src/organize/organize.cpp @@ -174,6 +174,7 @@ void Organize::ProcessSomeFiles() { // Fiddle the filename extension as well to match the new type song.set_url(QUrl::fromLocalFile(Utilities::FiddleFileExtension(song.basefilename(), task.new_extension_))); song.set_basefilename(Utilities::FiddleFileExtension(song.basefilename(), task.new_extension_)); + task.song_info_.new_filename_ = Utilities::FiddleFileExtension(task.song_info_.new_filename_, task.new_extension_); // Have to set this to the size of the new file or else funny stuff happens song.set_filesize(QFileInfo(task.transcoded_filename_).size()); diff --git a/src/organize/organizedialog.cpp b/src/organize/organizedialog.cpp index 04a0854cc..5ab96cb0b 100644 --- a/src/organize/organizedialog.cpp +++ b/src/organize/organizedialog.cpp @@ -68,6 +68,9 @@ #include "organizedialog.h" #include "organizeerrordialog.h" #include "ui_organizedialog.h" +#ifdef HAVE_GSTREAMER +# include "transcoder/transcoder.h" +#endif const char *OrganizeDialog::kDefaultFormat = "%albumartist/%album{ (Disc %disc)}/{%track - }{%albumartist - }%album{ (Disc %disc)} - %title.%extension"; @@ -405,7 +408,7 @@ void OrganizeDialog::InsertTag(const QString &tag) { ui_->naming->insertPlainText("%" + tag); } -Organize::NewSongInfoList OrganizeDialog::ComputeNewSongsFilenames(const SongList &songs, const OrganizeFormat &format) { +Organize::NewSongInfoList OrganizeDialog::ComputeNewSongsFilenames(const SongList &songs, const OrganizeFormat &format, const QString &extension) { // Check if we will have multiple files with the same name. // If so, they will erase each other if the overwrite flag is set. @@ -414,7 +417,7 @@ Organize::NewSongInfoList OrganizeDialog::ComputeNewSongsFilenames(const SongLis Organize::NewSongInfoList new_songs_info; for (const Song &song : songs) { - QString new_filename = format.GetFilenameForSong(song); + QString new_filename = format.GetFilenameForSong(song, extension); if (filenames.contains(new_filename)) { QString song_number = QString::number(++filenames[new_filename]); new_filename = Utilities::PathWithoutFilenameExtension(new_filename) + "(" + song_number + ")." + QFileInfo(new_filename).suffix(); @@ -473,7 +476,15 @@ void OrganizeDialog::UpdatePreviews() { ui_->button_box->button(QDialogButtonBox::Ok)->setEnabled(ok); if (!format_valid) return; - new_songs_info_ = ComputeNewSongsFilenames(songs_, format_); + QString extension; +#ifdef HAVE_GSTREAMER + if (storage && storage->GetTranscodeMode() == MusicStorage::Transcode_Always) { + const Song::FileType format = storage->GetTranscodeFormat(); + TranscoderPreset preset = Transcoder::PresetForFileType(format); + extension = preset.extension_; + } +#endif + new_songs_info_ = ComputeNewSongsFilenames(songs_, format_, extension); // Update the previews ui_->preview->clear(); diff --git a/src/organize/organizedialog.h b/src/organize/organizedialog.h index 4fb742843..8444bf7e0 100644 --- a/src/organize/organizedialog.h +++ b/src/organize/organizedialog.h @@ -73,7 +73,7 @@ class OrganizeDialog : public QDialog { void SetCopy(bool copy); - static Organize::NewSongInfoList ComputeNewSongsFilenames(const SongList &songs, const OrganizeFormat &format); + static Organize::NewSongInfoList ComputeNewSongsFilenames(const SongList &songs, const OrganizeFormat &format, const QString &extension = QString()); void SetPlaylist(const QString &playlist); diff --git a/src/organize/organizeformat.cpp b/src/organize/organizeformat.cpp index 7b1cdb6eb..c8d02d16d 100644 --- a/src/organize/organizeformat.cpp +++ b/src/organize/organizeformat.cpp @@ -108,7 +108,7 @@ bool OrganizeFormat::IsValid() const { } -QString OrganizeFormat::GetFilenameForSong(const Song &song) const { +QString OrganizeFormat::GetFilenameForSong(const Song &song, QString extension) const { QString filename = ParseBlock(format_, song); @@ -144,7 +144,7 @@ QString OrganizeFormat::GetFilenameForSong(const Song &song) const { filename = filename.simplified(); QFileInfo info(filename); - QString extension = info.suffix(); + if (extension.isEmpty()) extension = info.suffix(); QString filepath; if (!info.path().isEmpty() && info.path() != ".") { filepath.append(info.path()); diff --git a/src/organize/organizeformat.h b/src/organize/organizeformat.h index e98f20a74..9a48e9940 100644 --- a/src/organize/organizeformat.h +++ b/src/organize/organizeformat.h @@ -65,7 +65,7 @@ class OrganizeFormat { void set_replace_spaces(const bool v) { replace_spaces_ = v; } bool IsValid() const; - QString GetFilenameForSong(const Song &song) const; + QString GetFilenameForSong(const Song &song, QString extension = QString()) const; class Validator : public QValidator { public: