Moving a File

J. Landman Gay jacque at hyperactivesw.com
Tue Mar 6 15:47:08 EST 2007


Dave wrote:
> 
> a)  I'm not running Unix!

Revolution was originally created for Unix only, and many of its 
commands and syntax structures mirror that. For example, we use forward 
slashes ("/"), a unix convention, in all file paths regardless of the OS 
the engine is running on. The original engine, MetaCard, ran exclusively 
on unix systems for many years before a port to Windows was created, and 
a couple more years after that before it moved to Macintosh. You will 
find many commands in the documentation that are unix-only and have no 
effect in other operating systems. All these reflect the original 
MetaCard roots of the engine.


> b)  In  the Unix the Command is "mv" (for move) and, AFAIR you can say: 
> mv /FolderA/FolderB/FolderC/Filex.xxx /FolderA/FolderB/FolderX/ which is 
> what I was doing in the first place!

I decided to look this up. The man entry for mv shows two forms of 
syntax. The first form, which is the assumed default, is the one that 
Revolution uses, and requires a file path for both parameters. The 
second form is similar to the one you quote, but your method would 
produce an error. The man entry says "It is an error for either the 
source operand or the destination path to specify a directory unless 
both do." The second form is apparently intended to move the file 
contents of whole directories from one folder to another.

> 
> I just don't get it, you take the Unix "move" command, call it "rename" 
> and then stop it working like "move".

That doesn't seem to be the case. Revolution's rename command (which 
doesn't exist in unix) is mapped to the mv command (which does) and uses 
the first form, which is also the default form. I see below that there 
are several flags which affect whether the mv command will prompt before 
overwriting a file. I assume that to keep things simple, MetaCard used 
no flags in its interpretation of the mv command and assumed the 
developer would handle fie duplicates in scripts.

Here's the first part of the man entry, for reference:

SYNOPSIS
      mv [-f | -i | -n] [-v] source target
      mv [-f | -i | -n] [-v] source ... directory

DESCRIPTION
      In its first form, the mv utility renames the file named by the source
      operand to the destination path named by the target operand.  This 
form
      is assumed when the last operand does not name an already existing 
directory.

      In its second form, mv moves each file named by a source operand to a
      destination file in the existing directory named by the directory 
operand.  The destination path for each operand is the pathname produced by
      the concatenation of the last operand, a slash, and the final pathname
      component of the named file.

      The following options are available:

      -f      Do not prompt for confirmation before overwriting the 
destination
              path.  (The -f option overrides any previous -i or -n 
options.)

      -i      Cause mv to write a prompt to standard error before moving 
a file
              that would overwrite an existing file.  If the response 
from the
              standard input begins with the character `y' or `Y', the 
move is
              attempted.  (The -i option overrides any previous -f or -n
              options.)

      -n      Do not overwrite an existing file.  (The -n option 
overrides any
              previous -f or -i options.)

      -v      Cause mv to be verbose, showing files after they are moved.

      It is an error for either the source operand or the destination 
path to
      specify a directory unless both do.


-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com



More information about the use-livecode mailing list