0

Is there a preferred/customary way of formatting a filename that contains multiple words? Or is it a matter of personal choice? I'm trying to make more use of command line, if that makes a difference. (I do know that filenames containing spaces need to be quoted in command line.)

e.g:

  • Change Of Address Cards.odt
  • ChangeOfAddressCards.odt
  • Change_Of_Address_Cards.odt
  • Change-Of-Address-Cards.odt
  • change-of-address-cards.odt

etc. etc. ...

  • 4
    I think it's personal choice, unless in a corporate or like environment that has a policy for such things. – guiverc Aug 31 '19 at 00:19
  • See https://pclosmag.com/html/Issues/201607/page03.html. – DK Bose Aug 31 '19 at 01:26
  • 1
    @DKBose That is an excellent resource. It will be great if you could summarize the salient points in an answer. – user68186 Aug 31 '19 at 01:28
  • @user68186 I started posting an answer but realised that I'd just be quoting extensively from that resource and that doing so wouldn't be as useful as reading the article and the author's reasoning. – DK Bose Aug 31 '19 at 02:14

3 Answers3

2

I rarely type complete file names in the terminal. Instead I navigate to the parent directory of the file, sometimes type ls to show what files are contained in that directory, then type the first few letters of the file and autocomplete the full name of the file by pressing the Tab key.

Following the Ubuntu motto "Linux for human beings", it doesn't matter what pattern the file names are formatted in as long as it's easy for human beings to read. The easiest format to read is ordinary text with the words separated by spaces. If the files are part of a series like the songs in an album, I precede the file name with its sequence number in the series like nn track name where nn starts with a 0 for padding if the track number has only one digit like 01 instead of 1. That way 10 comes after 09 in the terminal results of ls and in all audio/video devices instead of coming after 1.

karel
  • 114,770
1

I generally agree with https://pclosmag.com/html/Issues/201607/page03.html
(provided by @DK Bose in a comment)

There are points that can be made against some of it though, but enough of that.

Based on experience built starting with very early PCs when:

  • sharing files with numerous computer brands and devices of other kinds,
  • scripting and programming
  • exchanging files and data with co-workers, colleagues and friends
  • plus avoiding numerous aspects and issues...

I have come to restrict file naming to the characters in these sets:
a-z, A-Z, 0-9 and -_
... with the additional . restricted to be the leading character for any file extension (or as 'hidden file` indicator when in Linux).

Glorfindel
  • 971
  • 3
  • 13
  • 20
Hannu
  • 5,374
  • 1
  • 23
  • 40
0

Why Bother?

The right question is why do you want to convert the spaces (optionally UPPER case) in multi-word filenames into something else?

Normal Desktop Use

If you are a desktop user who uses LibreOffice to create and edit documents for personal, then I don't see any reason to change. You will probably only use the File > Open dialog in LibreOffice to open the files. Or you may use Nautilus (Gnome Files) to go to the folder and double click on the a file to open it. These normal day-to-day activities do not require removal of space (optionally UPPER case) from filenames.

If you occasionally (or regularly) share these files with Windows or Mac users, then too I don't see any problem. All modern OSs can handle spaces in filenames. I get MSWord files from Windows users everyday that have spaces (and UPPER cases) in names. I open them in LibreOffice without any need to rename them.

Command-line and Scripts

If you use command-line or scripts to manipulate these files everyday, then it may make sense to convert them using some convention as described in other answers. If you like to torture yourself you can always type

Change\ Of\ Address\ Cards.odt

on a terminal. Or enclose it in quotes:

"Change Of Address Cards.odt"

If you can write your own bash (or any other) scripts then you can probably make the script smart enough to use quotes to enclose file names with spaces.

In this case, having spaces and UPPER cases in file names may need a bit of extra typing or more careful script writing, but may not be a deal breaker.

If you work with scripts written by others, and these scripts don not handle space and UPPER cases in filenames well, then you need to change the filenames.

Web based document repository

If you are building a web based document storage, where the filenames will be stored in a database, and they will be accessed as web URL, then it may be a problem if you have spaces and UPPER cases in the names as URLs don't handle spaces and UPPER cases well. The web-server you use may or may not make the conversion for you. If it does not, you definitely need to rename your files and you need to create and adhere to a convention to be consistent.

Others

There may be other scenarios where you may want to get rid of spaces in filenames. In those cases, your specific needs may determine what conversion convention you will need to follow.

Hope this helps

user68186
  • 33,360