20

I have set of temp files created in my folder with .bak extensions. How can I make them hide by default in Ubuntu?

I tried adding a .hidden file with *.bak as entry in the file, but that is not working. Any help is very appreciated...

4
  • 1
    IMO you're trying to fix the problem at the wrong end. If a program creates lots of backup files, it should put them in a dedicated folder and not spam them somewhere else.
    – htorque
    Nov 6, 2010 at 13:55
  • i have a shared dropbox folder where the backup files are getting created by another shared user. So i cant change it at that end. Need to fix at my end...
    – james
    Nov 6, 2010 at 14:05
  • I found this post (ubuntu forums). I hope this can help you. ubuntuforums.org/showthread.php?t=789684
    – i.raynov
    Nov 6, 2010 at 14:08
  • I think the question also applies to auxiliary files generated by compilers. The feature to hide files in Nautilus would be great to have. @htorque, It is not realistic to ask users to reprogram software that generate useless files. Even if the files have some use, it can still be desirable the possibility to hide them.
    – mnr
    Jul 27, 2015 at 14:29

4 Answers 4

3

The .hidden file does not support wildcards; you have to put the actual filenames there, which of course will vary per project. To make this process more convenient, I came up with a Bash alias that can be used to dynamically create the .hidden file with the names of the LaTeX intermediate files present in the current folder:

alias hidetex='ls *?(aux|bbl|blg|brf|lof|log|lot|out|toc) -1 > .hidden'

I added this line to the ~/.bash_aliases file, so now I can just cd to the folder with files I want to hide, and type hidetex.

This is intended to be executed at specific folders, but you could make it more generic (e.g. for .bak files) and change it to perform the task recursively, adding a .hidden file to each subfolder of a given root folder, but that's a little more complicated.

1

You could create a file called .hidden in your home directory. In this file you can put the names of all the files that you would like to be hidden, one per line.

0

If you place a full stop (or period) at the beginning of the name of the file it should hide it, for example:

.helloworld.txt

To view your now hidden file, click "view" on Nautilus then check "Show Hidden Files".

1
  • 2
    Thank you for the tip. But they are created by a program, i cant rename each of them.
    – james
    Nov 6, 2010 at 14:04
0

If you and the program don't care about the name of the file, try this command:

for annoyingbak in *.bak; do mv "$annoyingbak" ."$annoyingbak"; done

Then run it whenever you're annoyed by the .baks. It moves every file named bla.bak to .bla.bak.

If you have to do it very often, add this to the end of your .bashrc:

function deannoy {
    for annoyingbak in *.bak; do 
        mv "$annoyingbak" ."$annoyingbak"
    done
}

Then you can just type deannoy in your Dropbox folder and they're gone.

2
  • I suggest you read Bash Pitfalls points 1 and 2.
    – htorque
    Nov 6, 2010 at 15:03
  • oh hehe... I just use bash for the things I need in everyday tasks I (obv.) never really learned it. Good advice thanks! mv *.bak *.bak~ is the better way anyway
    – turbo
    Nov 6, 2010 at 16:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .