+// If from = /path/file.ext and to = /path2/file2.ext2 then this method
+// moves each /path/file*.ext file to /path2/file2*.ext2'
+bool Converters::move(string const & from, string const & to, bool copy)
+{
+ if (from == to)
+ return true;
+
+ bool no_errors = true;
+ string const path = OnlyPath(from);
+ string const base = OnlyFilename(ChangeExtension(from, ""));
+ string const to_base = ChangeExtension(to, "");
+ string const to_extension = GetExtension(to);
+
+ vector<string> files = DirList(OnlyPath(from), GetExtension(from));
+ for (vector<string>::const_iterator it = files.begin();
+ it != files.end(); ++it)
+ if (prefixIs(*it, base)) {
+ string const from2 = path + *it;
+ string to2 = to_base + it->substr(base.length());
+ to2 = ChangeExtension(to2, to_extension);
+ lyxerr[Debug::FILES] << "moving " << from2
+ << " to " << to2 << endl;
+ bool const moved = (copy)
+ ? lyx::support::copy(from2, to2)
+ : rename(from2, to2);
+ if (!moved && no_errors) {
+ Alert::error(_("Cannot convert file"),
+ bformat(_("Could not move a temporary file from %1$s to %2$s."),
+ from2, to2));
+ no_errors = false;
+ }
+ }
+ return no_errors;