diff scripts/miscellaneous/movefile.m @ 6233:a299c8a6d96e

[project @ 2007-01-09 04:31:18 by jwe]
author jwe
date Tue, 09 Jan 2007 04:33:46 +0000
parents 12b676a0b183
children 9bd49ed48ee6
line wrap: on
line diff
--- a/scripts/miscellaneous/movefile.m	Mon Jan 08 19:54:08 2007 +0000
+++ b/scripts/miscellaneous/movefile.m	Tue Jan 09 04:33:46 2007 +0000
@@ -40,6 +40,7 @@
   ## over the command that is executed.
 
   if (ispc () && ! isunix () && isempty (file_in_path (EXEC_PATH, "mv")))
+    ## Windows.
     cmd = "cmd /C move";
     cmd_force_flag = "/Y";
   else
@@ -48,17 +49,29 @@
   endif
 
   if (nargin == 2 || nargin == 3)
+    ## Input type check.
+    if (! (ischar (f1) || iscellstr (f1)))
+      error ("copyfile: first argument must be a character string or a cell array of character strings");
+    endif
+
+    if (! ischar (f2))
+      error ("copyfile: second argument must be a character string");
+    endif
+
     if (nargin == 3 && strcmp (force, "f"))
       cmd = strcat (cmd, " ", cmd_force_flag);
     endif
 
-    ## Allow cell input and protect the file name(s).
-    if (iscellstr (f1))
-      f1 = sprintf("\"%s\" ", f1{:});
-    else
-      f1 = sprintf("\"%s\" ", f1);
+    ## If f1 isn't a cellstr convert it to one.
+    if (ischar (f1))
+      f1 = cellstr (f1);
     endif
+    
+    ## Protect the file name(s).
+    f1 = glob (f1);
+    f1 = sprintf ("\"%s\" ", f1{:});
 
+    ## Move the file(s).
     [err, msg] = system (sprintf ("%s %s \"%s\"", cmd, f1, f2));
     if (err < 0)
       status = false;