Changing the photos folder in F-Spot

After I moved my stuff to a new hard disk, F-Spot couldn’t find my photos anymore. The path to the photos folder had changed, because I adopted a new user name. If you ever get yourself in this situation, here are some steps to fix the sqlite database.

After you move your photos, set the corresponding F-Spot preference. If you are moving to a new partition or HD, make sure you bring the database too: ~/.gnome2/f-spot/photos.db. Remember, you really should make a backup before you mess with the database! Now, open a copy of the database:

$ sqlite3 photos.db
SQLite version 3.5.6
Enter “.help” for instructions
sqlite> select id, uri from photos;



You have to see how long is the URI part you want to fix. If you want to change “Photos” for “Fotografias”, you’ll have to change everything from “file://” to “Photos”. In that case, the command would be:

sqlite> update photos set uri = ‘file:///home/usuario/Fotografias’|| substr(uri,28);

The number 28 is the lenght of “file:///home/usuario/Photos”, plus 1 (don’t ask me why). Now, check if you did it right:

sqlite> select id, uri from photos;



The result (correct or not) is already written to the file. If you did a mistake, you can try to fix it, or start over. Remember to keep a backup… To exit sqlite, the command is:

sqlite> .quit

I tested these exact steps, as well as changing only the user name (which is what I needed). I guess it’ll work with spaces and special characters, but I can’t guarantee. If you try it, tell me in the comments!

Thanks: This article was made possible because of Roland Mas, who gave me a link to the original instructions in the F-Spot mailing list. Those instructions didn’t fit exactly my situation (e. g. I had “uri” instead of “directory_path”), so I decided to gather his aditional tips in this article.

15 respostas em “Changing the photos folder in F-Spot

  1. I thought about that, but then I agreed it’s not a good practice to have users editing the database by hand. I believe this information belongs to an addin (plugin, etc.). I’m not a hacker, but I really hope someone scratches that itch.

  2. I’ve had to do this before, not because of a username change, but just out of convenience.. I wrote up a little guide that I haven’t yet “published”.. here it is..

    BACKUP ~/.gnome2/f-spot/photos.db

    Run the command:
    sqlite3 ~/.gnome2/f-spot/photos.db .dump > f-spot.dump

    Using whatever method, e.g. the find/replace feature in a text editor, change the information and settings you want to change in the f-spot.dump file.

    Delete ~/.gnome2/f-spot/photos.db

    Run the command:
    sqlite3 ~/.gnome2/f-spot/photos.db

  3. I’ve done similar operation with Banshee some time ago. Since I know the sql not so much I have done it with support of irb or python (I don’t remember). It allowed me to do it in steps:
    1. Open the connection
    2. Get data and print
    3. Get data change it (i.e. in local memory) and print
    4. Get data change it and write to the file
    5. Flush, close the connection etc.

    If it was a real application I would learn correct commands of the SQL. However since it was run once it allow me to ommit ’28’.

    Is it not be better style if it was:
    update photos set uri = ‘file:///home/usuario/Fotografias’|| substr(uri,length(‘file:///home/usuario/Photos’));

  4. > The result (correct or not) is already written to the file. If you did a mistake, you can try to fix it, or start over. Remember to keep a backup…

    You could also start a transaction before modifying the database. When you are satisfied with the changes, you can commit the transaction, but if you made a mistake, you can rollback and the database is still intact.

    sqlite> begin;
    sqlite> some sql statement here
    sqlite> commit; (or rollback;)

  5. > You could also start a transaction before modifying the database.

    I know. I know ;). But to program it in some kind of scripting language is by far more transparent and UF for me. As I said in real-live application I would use SQL.

  6. Hi, thanks for the tips.
    I think updating the path would be easuer using replace syntax – saves you from counting characters 😉

    update photos set uri = replace(uri,’/home/olduser/’,’/home/newuser/’);

  7. Olá, Leonardo!
    Sou aluna de Jornalismo, do Brasil.
    Estou fazendo uma matéria para o nosso jornal-laboratório da faculdade sobre o novo acordo ortográfico e estava procurando informações a respeito quando achei esse texto seu…
    Precisava de alguém de Portugal para retratar a opinião na minha matéria. Você poderia me ajudar?
    Se possível, responda às questões abaixo e me envie a resposta o quanto antes (pois estou fechando a matéria já) acompanhado de uma foto sua.

    – Como você vê essa mudança na gramática portuguesa? Favor ou contra/ E por que?
    – Qual é o posicionamento dos portugueses diante desta questão?

    Só confirmando.. preciso do seu nome completo, função que exerce no dia-a-dia e onde mora.

    Angélica Neri – Brasil.

Deixe um comentário

Preencha os seus dados abaixo ou clique em um ícone para log in:

Logotipo do

Você está comentando utilizando sua conta Sair /  Alterar )

Foto do Google

Você está comentando utilizando sua conta Google. Sair /  Alterar )

Imagem do Twitter

Você está comentando utilizando sua conta Twitter. Sair /  Alterar )

Foto do Facebook

Você está comentando utilizando sua conta Facebook. Sair /  Alterar )

Conectando a %s