+// 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 path = OnlyPath(from);
+ string base = OnlyFilename(ChangeExtension(from, ""));
+ string to_base = ChangeExtension(to, "");
+ string 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 from2 = path + *it;
+ string to2 = to_base + (*it).substr(base.length());
+ to2 = ChangeExtension(to2, to_extension);
+ lyxerr << "moving " << from2 << " to " << to2 << endl;
+ bool moved = (copy)
+ ? lyx::copy(from2, to2)
+ : lyx::rename(from2, to2);
+ if (!moved && no_errors) {
+ WriteAlert(_("Error while trying to move file:"),
+ from2, _("to ") + to2);
+ no_errors = false;
+ }
+ }
+ return no_errors;
+}