diff --git a/kerfuffle/addtoarchive.cpp b/kerfuffle/addtoarchive.cpp --- a/kerfuffle/addtoarchive.cpp +++ b/kerfuffle/addtoarchive.cpp @@ -239,12 +239,18 @@ QString AddToArchive::detectBaseName(const QStringList &paths) const { - QString base = QFileInfo(paths.first()).absoluteFilePath(); + QFileInfo file = QFileInfo(paths.first()); + QDir dir = file.dir(); + QString base = dir.absolutePath() + QLatin1Char('/'); + if (paths.size() > 1) { - QDir dir = QFileInfo(paths.first()).dir(); if (!dir.isRoot()) { - base = dir.absolutePath() + QLatin1Char('/') + dir.dirName(); + //use directory name for the new archive + base += dir.dirName(); } + } else { + // strip filename of its extension + base += file.baseName(); } if (base.endsWith(QLatin1Char('/'))) {