Skip to content

Commit

Permalink
Merge branch 'handle-dots-in-file-names'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jojo-Schmitz committed Mar 13, 2018
2 parents 8bc2bcd + 1d3e39e commit 7ae6a07
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions batch_convert.qml
Expand Up @@ -685,6 +685,23 @@ MuseScore {
}
}

// FolderListModel returns what Qt calles the
// completeSuffix for "fileSuffix" which means everything
// that follows the first '.' in a file name. (e.g. 'tar.gz')
// However, this is not what we want:
// For us the suffix is the part after the last '.'
// because some users have dots in their file names.
// Qt::FileInfo::suffix() would get this, but seems not
// to be available in FolderListModel.
// So, we need to do this ourselves:
function getFileSuffix(fileName) {

var n = fileName.lastIndexOf(".");
var suffix = fileName.substring(n+1);

return suffix
}

// This timer contains the function that will be called
// once the FolderListModel is set.
Timer {
Expand All @@ -705,12 +722,12 @@ MuseScore {
// traverse it, so add it to folderList
if (files.isFolder(i)) {
folderList.push(files.get(i, "fileURL"))
} else if (inInputFormats(files.get(i, "fileSuffix"))) {
} else if (inInputFormats(getFileSuffix(files.get(i, "fileName")))) {
// found a file to process
// set file names for in and out files
var shortName = files.get(i, "fileName")
var fileName = files.get(i, "filePath")
var fileSuffix = files.get(i, "fileSuffix")
var fileSuffix = getFileSuffix(shortName);
var fileBase = fileName.substring(0, fileName.length - fileSuffix.length - 1)
fileList.push([shortName, fileName, fileBase])
}
Expand Down

0 comments on commit 7ae6a07

Please sign in to comment.