Naming Files

Just as files are named in the manual system, computer files too are given names. A disk will not necessarily contain only one file. It will probably have more than one file and you may need to refer to a specific file. Hence there is a need for file names. A file name should be descriptive and meaningful. Certain conventions are followed while naming computer files. A file name can have two parts:

  • Primary name
  • Extension

The primary name and the extension are separated by a dot (.)

File Naming Conventions

File Naming Conventions

A primary name can have a maximum of eight characters while an extension can have a maximum of three characters.

A file name is valid even if it has no extension. However, extensions help in easy identification of a particular type of file. Therefore, a picture file has an extension of .bmp, a text file has an extension of .txt, and a program file has an extension of .prg and so on. File names can consist of the following characters:

  • An alphabet                        (A-Z)
  • A numeral                           (0-9)
  • Other characters                 ($, #,&,©,!, %, (), -, _, {},', ~,A) except ( \, /, *, ?, <>, and | )

While files are named by the people who create them, certain conventions are followed. Also, each file in a particular location on a disk needs to have a unique name.

Examples of some valid file names are:

  • EMPLOYEE.DAT
  • EXECUTIVE.T
  • XYZ
  • 123.45
  • HRD.RPT

The file name that you give must be meaningful. Meaningful file names enable easy identification of files. For example, if you want to create a file containing salary details of the employees, the name given to the file could be EMP.SAL or SALARY. These names indicate that these files contain data on salaries of employees.

If you were to name this file as XYZ.123 or $%$.TEN, you are most likely to forget the name of the file. Besides, the filename also does not convey what the file contains. Similarly, if your file contains a report of the financial status of a company, a name like FINANCE.RPT would make more sense than, say ABC.PQR.