diff --git a/src/exiv2.cpp b/src/exiv2.cpp index beac204b..ba4169bd 100644 --- a/src/exiv2.cpp +++ b/src/exiv2.cpp @@ -334,16 +334,23 @@ int Params::evalRename(int opt, const std::string& optarg) case Action::none: action_ = Action::rename; switch (opt) { - case 'r': format_ = optarg; break; + case 'r': + format_ = optarg; + formatSet_ = true; + break; case 't': timestamp_ = true; break; case 'T': timestampOnly_ = true; break; } break; case Action::rename: - if (opt == 'r' && !format_.empty()) { + if (opt == 'r' && (formatSet_ || timestampOnly_)) { std::cerr << progname() << ": " << _("Ignoring surplus option") << " -r \"" << optarg << "\"\n"; } + else { + format_ = optarg; + formatSet_ = true; + } break; default: std::cerr << progname() diff --git a/src/exiv2.hpp b/src/exiv2.hpp index 89ab9b86..283f950a 100644 --- a/src/exiv2.hpp +++ b/src/exiv2.hpp @@ -164,6 +164,7 @@ public: long adjustment_; //!< Adjustment in seconds. std::string format_; //!< Filename format (-r option arg). + bool formatSet_; //!< Whether the format is set with -r CmdFiles cmdFiles_; //!< Names of the modification command files CmdLines cmdLines_; //!< Commands from the command line ModifyCmds modifyCmds_; //!< Parsed modification commands @@ -195,6 +196,7 @@ private: target_(ctExif|ctIptc|ctComment), adjustment_(0), format_("%Y%m%d_%H%M%S"), + formatSet_(false), first_(true) {} //! Prevent copy-construction: not implemented.