How to hide (in Thunar and Nautilus) a directory without putting a dot in its name?

Nautilus (Update: This should also work with Thunar now) will hide any file or folder that is listed in the file .hidden located in the same directory.

There are two ways to hide a folder in Nautilus:

Nautilus script

  1. Save the following code in a new file in your home folder. Name it Hide.

    #!/usr/bin/env python
    
    import commands
    from os.path import join
    
    
    files = commands.getoutput("echo $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS")
    cwd = commands.getoutput("echo $NAUTILUS_SCRIPT_CURRENT_URI")
    cwd = cwd[7:]
    
    for f in files.split(" /"):
    
        f = f.split("/")[-1]
    
        commands.getoutput("echo "+f+" >> "+join(cwd, ".hidden"))
    
  2. Run the following command to install the script:

    cp Hide ~/.local/share/nautilus/scripts/ && chmod u+x ~/.local/share/nautilus/scripts/Hide
    
  3. In Nautilus, select one or more files/folders and right click. Select Hide from the Scripts menu:

    enter image description here

    Reload the current location ( F5 ) and the selected files/folders will be hidden.

Command line

Say you want to hide a folder called "Rick Astley's Greatest Hits", just run the following command:

echo "Rick Astley's Greatest Hits" >> .hidden