AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Firefox Profile Backuper

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
k3ph



Joined: 20 Jul 2006
Posts: 174

PostPosted: Wed Jun 18, 2008 2:37 pm    Post subject: Firefox Profile Backuper Reply with quote

[ Information ]
This is my old simple batch profile backuper ported to AHK.
It works with any version of Firefox

**Tested with Firefox 2 and Firefox 3**

Notes for Devs: oh yeah, some people asking me about to mod this script, feel free to do whatever ;) enjoy.

[ Screenshot ]


[ Download ]
fpb.v01.ahk - size: 2.36KB

fpb.exe - size 179KB

[ Source ]
Code:
#NoEnv
SendMode Input
SetTitleMatchMode 2
SetWorkingDir %A_ScriptDir%
#SingleInstance Force
#Persistent
#NoTrayIcon

debug = 0
version = v01
backup = %A_ScriptDir%\backup
profilesfile := % A_AppData . "\Mozilla\Firefox\profiles.ini"

Gui,Add,Text,, [ guidraft by ChalamiuS && code by k3ph ]`n[ thanks to derRaphael && Titan ]
Gui,Add,Text,, The following files will be backuped:
Gui,Add,Text,,   bookmarks.html - Bookmarks.`n  prefs.js - Current user preferences.`n  user.js - User-added preferences (overrides prefs.js every startup).`n  signons.txt - Saved passwords.`n  key3.db - Supplements password file.`n  cert8.db - Needed for key3.db file
Gui,Add,Text,, Information regarding to upgrade:
Gui,Add,Text,,   the file bookmarks.html can be directly copied in the new profile folder.`n  Its not recommended copying to a different version of Firefox: user.js and prefs.js files. `n  Copying signons.txt, key3.db and cert8.db are recommended only with same Firefox versions.
Gui,Add,Button,gbackup x50 y170 v1,backup
Gui,Add,Button,gExit x140 y170 v2,exit
Gui,Show,w470 h270, Firefox Profile Backuper

GuiControl,Move,1,% "y" 266*0.90
GuiControl,Move,2,% "y" 266*0.90
return

backup:
IfExist, %profilesfile%
   FileRead, maindata, %profilesfile%
   
   count := 0
   Loop, parse, maindata, `n, `r
   {
      founded := RegExMatch(A_LoopField, "Profile\d+", match)
      If match
         if ErrorLevel = 0
            count++
            matches .= match
   }
   profiles := RegExReplace(matches, "(?<!^)(Profile\d+)", "|$1")
   Gui, 2:Add, ListBox, vProfile gAddProfile, %profiles%
   Gui, 2:Show,, choose profile
return

AddProfile:
   If (A_GuiEvent = "Normal")
      return
   Gui,2:Submit
   Gui,2:Destroy
   if (Profile == "") {
      msgbox please select a profile
      reload
   } else {
      if (debug = 1) {
         MsgBox, %count% profiles detected`nChosen List: %A_EventInfo%`nProfile: %Profile%
      }
      iniread, profilespath, %profilesfile%, %Profile%, Path
      stringreplace, profilespath, profilespath, Profiles/, , All
      path = %A_AppData%\Mozilla\Firefox\Profiles\%profilespath%\
      if (debug = 1) {
         MsgBox, ProfilesPath: %profilespath%`nAbsolute Path: %path%
      }
      IfNotExist, %backup%
         FileCreateDir, %backup%
      files = bookmarks.html,signons.txt,prefs.js,user.js,bookmarks.html,key3.db,cert8.db
      loop, Parse, files, `,
      {
         FileCopy, %path%\%A_LoopField%, %backup%
      }
      gosub exit
   }
return

exit:
   ExitApp
return


additional for greasemonkey scripts:
Code:
FileCopy, %A_AppData%\Mozilla\Firefox\Profiles\%profilespath%\gm_scripts\*.js, %backup%\gm_scripts


[ keywords ]
firefox, ff1, ff2, ff3, backup

_________________
                                  [ profile | ahk.net | ahk.talk ]


Last edited by k3ph on Wed Jun 18, 2008 3:17 pm; edited 1 time in total
Back to top
View user's profile Send private message
Chala



Joined: 29 Mar 2008
Posts: 11

PostPosted: Wed Jun 18, 2008 3:05 pm    Post subject: Reply with quote

k3ph you modified the gui Sad you made it look odd Shocked
If you want it to look normal in 120dpi you'll have to modify it yourself Wink


It looks quite normal with the correct code in 96dpi

Code:

#NoEnv
SendMode Input
SetTitleMatchMode 2
SetWorkingDir %A_ScriptDir%
#SingleInstance Force
#Persistent
#NoTrayIcon

debug = 0
version = v01
backup = %A_ScriptDir%\backup
profilesfile := % A_AppData . "\Mozilla\Firefox\profiles.ini"

Gui,Add,Text,, [ guidraft by ChalamiuS && code by k3ph ]`n[ thanks to derRaphael && Titan ]
Gui,Add,Text,, The following files will be backuped:
Gui,Add,Text,,   bookmarks.html - Bookmarks.`n  prefs.js - Current user preferences.`n  user.js - User-added preferences (overrides prefs.js every startup).`n  signons.txt - Saved passwords.`n  key3.db - Supplements password file.`n  cert8.db - Needed for key3.db file
Gui,Add,Text,, Information regarding to upgrade:
Gui,Add,Text,,   the file bookmarks.html can be directly copied in the new profile folder.`n  Its not recommended copying to a different version of Firefox: user.js and prefs.js files. `n  Copying signons.txt, key3.db and cert8.db are recommended only with same Firefox versions.
Gui,Add,Button,gbackup x10 y170 v1,Backup
Gui,Add,Button,gExit x70 y170 v2,Exit
Gui,Show,w470 h270, Firefox Profile Backuper

GuiControl,Move,1,% "y" 270*0.90
GuiControl,Move,2,% "y" 270*0.90
return

backup:
IfExist, %profilesfile%
   FileRead, maindata, %profilesfile%
   
   count := 0
   Loop, parse, maindata, `n, `r
   {
      founded := RegExMatch(A_LoopField, "Profile\d+", match)
      If match
         if ErrorLevel = 0
            count++
            matches .= match
   }
   profiles := RegExReplace(matches, "(?<!^)(Profile\d+)", "|$1")
   Gui, 2:Add, ListBox, vProfile gAddProfile, %profiles%
   Gui, 2:Show,, choose profile
return

AddProfile:
   If (A_GuiEvent = "Normal")
      return
   Gui,2:Submit
   Gui,2:Destroy
   if (Profile == "") {
      msgbox please select a profile
      reload
   } else {
      if (debug = 1) {
         MsgBox, %count% profiles detected`nChosen List: %A_EventInfo%`nProfile: %Profile%
      }
      iniread, profilespath, %profilesfile%, %Profile%, Path
      stringreplace, profilespath, profilespath, Profiles/, , All
      path = %A_AppData%\Mozilla\Firefox\Profiles\%profilespath%\
      if (debug = 1) {
         MsgBox, ProfilesPath: %profilespath%`nAbsolute Path: %path%
      }
      IfNotExist, %backup%
         FileCreateDir, %backup%
      files = bookmarks.html,signons.txt,prefs.js,user.js,bookmarks.html,key3.db,cert8.db
      loop, Parse, files, `,
      {
         FileCopy, %path%\%A_LoopField%, %backup%
      }
      gosub exit
   }
return

exit:
   ExitApp
return
Back to top
View user's profile Send private message
shajul



Joined: 15 Sep 2006
Posts: 33
Location: India

PostPosted: Wed Jun 18, 2008 5:54 pm    Post subject: Very nice script - suggestions! Reply with quote

Thanks k3ph, works absolutely fine!!

i usually backup my entire profiles folder, so that it can be restored in totality! adding an option to do that will not be difficult!
Back to top
View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group