WORKING WITH DIRECTORIES IN VMS


This describes the basics of working with directories in a computer running VMS. You'll learn how to see the contents of your working directory, how to create and delete directories, and how to move among them.

1. Seeing the contents of a directory

To see the files contained in a directory you must issue the command DIRECTORY. As always in VMS you can abbreviate the command as long as it can not be confused with a different one (e. g. DIR)

| DIR

This shows you the contents of your current working directory (i. e. the place you are working in now).

2. Creating a new directory

To create a new directory inside the one you are working on, the command to use is CREATE/DIRECTORY. You must tell the name of the directory to be created preceded by a dot and enclosed in square brackets:

|
| CREATE/DIRECTORY [.my_subdirectory]
|

The square brackets tell the system that inside of them the name given is that of a directory.

Note that the dot before the name of the directory is absolutely required. This makes a new directory contained in the directory you are currently working on. (You can know where you are typing SHOW DEFAULT).

If you see the contents of your working directory now, you will see a new file:

       MY_SUBDIRECTORY.DIR;1

This file is the newly created directory (you can tell it because of the .DIR extension in the file name). To see the contents of this directory you would use now the command

|
| DIR [.my_subdirectory]
|

If the directory contains more subdirectories and you want to see the contents of one of them you must specify the path to reach it, separating the name of each directory that you must traverse with a dot

3. Moving across directories

As we have seen the system distinguishes directory names as they are enclosed in square brackets. Whenever we specify a name inside square brackets the system will think that we are speaking of a directory.

Your default directory is the one in which everything happens unless you tell the system otherwise.

You can tell the system to select a different directory to work in, i. e. to be used as the default for all subsequent commands (or to move to it) with the command SET DEFAULT

When you issue a SET DEFAULT command followed by the name of a directory all subsequent commands will take place in that new directory you said:

|DIR
|
|Directory $U:[USERNAME]
|
|FILE1.DAT;1	FILE2.DAT;1	SUBDIR.DIR;1	OTHERSUBDIR.DIR;1
|
|Total of 4 files.
|
|SET DEFAULT $U:[USERNAME.SUBDIR]
|
|DIR
|
|Directory $U:[USERNAME.SUBDIR]
|
|OTHERFILE.DAT;1	OTHERFILE.PLUS;2
|
|Total of 2 files.

You can specify a subdirectory by giving its name preceded by a dot:

|
| SET DEFAULT [.SUBDIR]
|

would have sufficed in the former example.

Since a directory may contain one or more (possibly lots) of sub-directories but it may be contained in only ONE parent directory, you can use a shortcut when you want to move from a sub-directory to its parent directory (the one it was contained in): a dash (-) specifies the parent of a subdirectory.

In the above example, once you are inside $U:[USERNAME.SUBDIR] you can move to $U:[USERNAME] directly by typing

|
| SET DEF [-]
|

which is easier.

You can combine directory names in a path telling the names of the directories to be traversed separated by dots.

In the example above

$U:[USERNAME.SUBDIR]

Meant "Go to disk '$U', enter 'USERNAME' and the go on to 'SUBDIR'" assuming that SUBDIR was inside USER which was located in the disk $U.

Or you could have moved from within SUBDIR contained in USER to OTHERSUBDIR which also was contained in USER by using

SET DEF [-.OTHERSUBDIR]

which is to say "given I am in SUBDIR, go to my parent directory (USERNAME), and then descend on to OTHERSUBDIR".

For instance, let's suppose that we have the following directory tree:

                  WORK
                  / \ 
                 /   \
               NUCL   PROT
                /\
               /  \
             DNA  RNA
             /
           NUCL

and that we are in the directory WORK. To know the contents of RNA use

|
| Dir [.nucl.rna]
|

To move into a directory you use the command SET DEFAULT and tell the directory to move into: e.g. if we were in WORK and wanted to move to DNA, we'd use

|
| SET DEF [.nucl.dna]
|

Now a DIR command without specifying any directory would show the contents of DNA.

If from DNA we wanted to know the contents of RNA, we must say how to go to there: first we must move upwards (to NUCL) and then down to RNA. We say that we want to go to the one NUCL tha is *upwards* using a dash (-):

|
| DIR [-.RNA]
|

To see the contents of PROT we would need to go up two levels:

|
| DIR [-.-.PROT]
|

You can use this way of referring to directories with other commands, e.g. being in NUCL, if you want to copy something from RNA to PROT use

|
| COPY [.RNA]some.seq [-.PROT]*
|

4. Deleting a directory

To delete a directory you must do it in three steps:

  1. Empty the directory from all its contents (both, files and subdirectories).
  2. Gain permission to delete it (by default it is created without delete permission to avoid deleting it by accident).
  3. Delete the directory

Directories are special files since they may contain more files inside of them. Deleting a directory could delete all of its contents which may be a catastrophe if you delete it by error.

For this reason the system doesn't allow you to delete a directory easily. First it protects it against you -the owner and creator- and then checks if it is empty before allowing to delete it.

So, if you try to delete it as a normal file you will get an error message like

|
| DELETE MY_DIRECTORY.DIR;
|
| %DELETE-W-FILNOTDEL, error deleting MY_DIRECTORY.DIR;1
| -RMS-E-PRV, insufficient privilege or file protection violation
|

Hence the first thing that you must do is override the protection, so as to be allowed to delete it:

|
| SET FILE my_directory.dir /PROTECTION=(OWNER:D)
|

This tells the system that we want the owner to have privilege to 'D'elete the file

Now we can delete it:

|
| DELETE MY_DIRECTORY.DIR;
|

For example, if we wanted to delete the directory RNA from WORK

|
| Del [Nucl.RNA]*.*;* 

would delete all files in RNA:

|
| Dir [Nucl.RNA]

should find NO files after that. Now we can change its protection:

|
| Set Protection=(O:d) [.Nucl]RNA.dir;*

this way we say that O, the owner of the directory (i.e. you), now has priviledges to D, delete, it.

|
| Del [.Nucl]RNA.dir;*

and finally we delete it.

5. Getting more information

You can learn more about directories issuing the following commands

HELP DIRECTORY

HELP SET DEFAULT

HELP CREATE /DIRECTORY

HELP HINTS Files_and_directories

[email protected]
[email protected]
[email protected]