Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I recently accidentally filled my home partition in Ubuntu. Before I realized what happened, I restarted Firefox because it was acting strangely (understandably).

Now, when I start firefox with the Profile Manager (using -p) it doesn't list any of my existing profiles. I checked and all the profile folders are still there but my profiles.ini file is basically empty. I presume it got blanked by accident while the partition was full.

I tried deleting the profiles.ini but it just gets regenerated empty. Is it possible to regenerate my profiles.ini based on the existing profile folders or will I just have to rebuild it by hand (the mozilla docs show the format so it doesn't look too hard to do, I'm just looking for the lazy option).

share|improve this question
add comment

2 Answers

Some Bash-love; name it whatever you like. I used thescript.sh

#!/bin/bash

echo '[General]'
echo 'StartWithLastProfile=1'
echo ''

n=0

for file in * ; do
  if [ -d $file ] ; then
     if [[ "$file" =~ .+\.(.+) ]] ; then
        echo "[Profile${n}]"
        echo "Name=${BASH_REMATCH[1]}"
    echo "IsRelative=1"
    echo "Path=${file}"
    if [[ ${BASH_REMATCH[1]} == default ]] ; then
       echo "Default=1"
    fi
    echo ""
    let n++
     fi
  fi
done

Usage

First, place it in your mozilla profiles directory (e.g. ~/.mozilla/firefox for me).

chmod +x thescript.sh
./thescript.sh
./thescript.sh > profiles.ini

Output

nex@Computer:~/.mozilla/firefox
> ./thescript.sh 
[General]
StartWithLastProfile=1

[Profile0]
Name=default
IsRelative=1
Path=03k202kd.default
Default=1

[Profile1]
Name=test
IsRelative=1
Path=a023lkdl.test


nex@Computer:~/.mozilla/firefox
> ./thescript.sh > profiles.ini
share|improve this answer
1  
Nice, I should have mentioned how to use mine as well. –  Rob Van Dam Feb 20 '10 at 6:45
add comment

I can't find anything googling so I wrote a perl script:

#!/usr/bin/perl

use strict;
use warnings;

my $dir = glob($ARGV[0] || '~/.mozilla/firefox/');

chdir $dir or die "Unable to change to dir $dir: $!";
opendir my $dh, $dir or die "Unable to open dir $dir: $!";
my @dirs = grep { /^[^.]/ && -d $_ } readdir $dh;

# print some boilerplate
print <<'START';
[General]
StartWithLastProfile=0

START

# try to sort by oldest first (uses a schwartzian transform)
# the 'chrome' folder in each profile folder seems to be the oldest file per profile generally
@dirs = reverse
        map { $_->[0] }
        sort { $a->[1] <=> $b->[1] || $a->[0] cmp $b->[0] }
        map { [ $_, -C "$_/chrome" ] }
        grep { -e "$_/chrome" } @dirs;

my $i = 0;
foreach my $profile_dir (@dirs) {
    # folder names are usually of the form zyxwabc.My Profile Name
    my ($name) = $profile_dir =~ /^[^.]+\.(.*)/;
    next if ! $name;

    print <<"PROFILE";
[Profile$i]
Name=$name
IsRelative=1
Path=$profile_dir

PROFILE

    $i++;
}
share|improve this answer
add comment

Your Answer

 
discard

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.