Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am making a script and I am looking for a way to get the variable names for Desktop, Music, Documents, Pictures and others Folders. Depending on the language they change. For example Desktop in Spanish is Escritorio. So how can I get the folder directory without needing to find out what language the user is using or having to make several IF statements for each language.

share|improve this question
up vote 3 down vote accepted

The common folder names are as follows. Just extracted from a file in home directory.


Of course, you are only interested in the variable name. So there are XDG_DESKTOP_DIR, XDG_DOWNLOAD_DIR, .... etc.

Related question: How can I change the default location of content directories (eg Pictures, Templates, Music) in my home folder?

Hope this will help.

share|improve this answer
Wow!. Thanks Anwar. Nice list. I got a little problem testing it. Doing echo on any of the variables throws nothing. I found the information in ~/.config//user-dirs.dirs but still the variables are empty. – Luis Alvarado Sep 28 '12 at 18:10
same here, i also don't see those variables in terminal (at least not by default). localized folder names drive me absolutely crazy. – kritzikratzi Oct 9 '12 at 18:14
@LuisAlvarado @ritzikratzi the default method to change these variables in change in ~/.config/user-dirs.dirs file. and I think these variables aren't available from terminal – Anwar Shah Oct 10 '12 at 2:56

Perhaps there's an easier way to do it, but this is what i've done:

For example, getting desktop folder:

desktopVar=$(cat $HOME/.config/user-dirs.dirs | grep "XDG_DESKTOP_DIR")
desktopFolder=$(echo ${desktopVar/XDG_DESKTOP_DIR=/""} | tr -d '"')
echo $desktopFolder

For other variables is analogous.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.