From db33ccf1094fab717bcb94134f5c87148942fce9 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Wed, 15 Dec 2010 00:02:33 -0500 Subject: [PATCH] Make the TVRenamer preserve file extensions. --- web_frontend/file.js | 14 ++++++++++++++ web_frontend/tv_renamer.js | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/web_frontend/file.js b/web_frontend/file.js index 6e0288d..a87783d 100644 --- a/web_frontend/file.js +++ b/web_frontend/file.js @@ -86,6 +86,20 @@ armadillo.File.prototype.isDirectory = function() { return this.isDirectory_; }; +/** + * Returns the extension of the file, or an empty string if theh file is a + * directory or does not have an extension. + * @returns string + */ +armadillo.File.prototype.getExtension = function() { + if (this.isDirectory()) + return ''; + var index = this.getName().lastIndexOf('.'); + if (index == -1) + return ''; + return this.getName().substring(index); +}; + /** * Sets the highlight state. */ diff --git a/web_frontend/tv_renamer.js b/web_frontend/tv_renamer.js index 4e142c3..782c5e4 100644 --- a/web_frontend/tv_renamer.js +++ b/web_frontend/tv_renamer.js @@ -113,6 +113,7 @@ armadillo.TVRenamer.prototype.buildURL_ = function(show, season, episode) { * @private */ armadillo.TVRenamer.prototype.rename_ = function(newName) { - var path = app.joinPath(this.file_.getParentPath(), newName); + var path = app.joinPath(this.file_.getParentPath(), + newName + this.file_.getExtension()); this.file_.move(path); }; -- 2.43.5