Wedge1 Posted August 23, 2005 Posted August 23, 2005 Can any of you create a script that will automatically export Firefox bookmarks to a destination of my choosing? i.e., I can edit the destination, but I have no idea how to make the actual script.If somebody can create this, I will have a way of scheduling the execution of this script, thus ensuring that my bookmarks will always be backed up in an on-going, hands-free manner.Much appreciation for anybody that can assist in this.I have also posted this question in the Firefox forum, but I figure more expertise on this topic can be found here
dman Posted August 23, 2005 Posted August 23, 2005 (edited) Really just one command will do it. Something like...@echo offcopy /Y C:\Documents and Settings\<USER>\Application Data\Mozilla\Firefox\Profiles\<zaz3ggmy>.default\bookmarks.html c:\backups\bookmarks.html Save that as "backupfox.cmd" or name of your choosingnote that your user profile will have a different random sequence than "zaz3ggmy", but the rest other than user name is default install path. Just edit the destination where you want it to go. Then just schedule it with task scheduleryou could also try Fab's autobackup for more complete solution...http://autobackup.parisot-net.com/index-en.htm Edited August 23, 2005 by dman
Wedge1 Posted August 23, 2005 Author Posted August 23, 2005 @echo offcopy /Y C:\Documents and Settings\Owner\Application Data\Mozilla\Firefox\Profiles\8loakqo3.default\bookmarks.html "I:\Firefox bookmarks\script test\bookmarks.html"What have i got wrong here?
dman Posted August 23, 2005 Posted August 23, 2005 (edited) you need quotes around any path with spaces. sorry, didn't make that clear.@echo offcopy /Y "C:\Documents and Settings\Owner\Application Data\Mozilla\Firefox\Profiles\8loakqo3.default\bookmarks.html""I:\Firefox bookmarks\script test\bookmarks.html" Edited August 23, 2005 by dman
gunsmokingman Posted August 23, 2005 Posted August 23, 2005 Here is the same cmd using the "%USERPROFILE% varibleEcho Off && Copy /y "%USERPROFILE%\Application Data\Mozilla\Firefox\Profiles\8loakqo3.default\bookmarks.html" "I:\Firefox bookmarks\script test\bookmarks.html"
Wedge1 Posted August 23, 2005 Author Posted August 23, 2005 Here is the same cmd using the "%USERPROFILE% varibleEcho Off && Copy /y "%USERPROFILE%\Application Data\Mozilla\Firefox\Profiles\8loakqo3.default\bookmarks.html" "I:\Firefox bookmarks\script test\bookmarks.html"<{POST_SNAPBACK}>Does this mean that any user that is logged on can use the script? i.e., what is the difference in this script vs. the other one already posted?
dman Posted August 23, 2005 Posted August 23, 2005 When script is run, %USERPROFILE% variable is replaced by the current user area (usually "documents and Settings") plus the currently logged-on users name. But without modifying the destination you would overwrite each others bookmarks whenever someone else is logged on. If you want to back up multiple users make a line for each one with a different source and destination. You can also use scripting to loop through the users but that is more complicated for beginner.
Wedge1 Posted August 23, 2005 Author Posted August 23, 2005 You can also use scripting to loop through the users but that is more complicated for beginner.<{POST_SNAPBACK}>Yes, I really don't need to loop it. I'm the only person who uses this PC.Appreciate your help dman.
Yzöwl Posted August 24, 2005 Posted August 24, 2005 You could have further shortened the line by replacing %USERPROFILE%\Application Data with %APPDATA%.Anyhow, here is a slightly different approach, which will also suit those of us not using the default profile name /location.@echo off&setlocal enableextensionsset backupdir=I:\Firefox bookmarks\script testfor /f "tokens=1,2* delims==" %%a in ( 'type "%AppData%\Mozilla\Firefox\profiles.ini"^|findstr/ib "path=" ^2^>nul') do ( if errorlevel 0 set profdir=%%~b)if defined profdir ( if not exist "%backupdir%\bookmarks.html" ( copy "%profdir%\bookmarks.html" "%backupdir%">nul ) else ( xcopy "%profdir%\bookmarks.html" "%backupdir%" /adcquy>nul ))endlocal&goto :eofJust change the location for your backups after the equals symbol on the second lineNoteThis will not work for those users with more than one firefox profile definedJust schedule the batch to run with AT or SCHTASKS.
dman Posted August 24, 2005 Posted August 24, 2005 Nice one, "Wise Owl" (finally got it when you changed your avatar).
gunsmokingman Posted August 24, 2005 Posted August 24, 2005 (edited) Here is a VBS version of the script I tested it with C:\TestMe.txt And %Systemdrive%It copies the file to the new location, if the file is there then it renames it with a Back at the end of the name.Green Text Is The Test It Can Be Removed From The ScriptRed Text Is Your File Remove ' from in front of the textExampleThis Wont Work Like This' Moz = (ApData & "Mozilla\Firefox\Profiles\8loakqo3.default\bookmarks.html")It Must look Like This Moz = (ApData & "Mozilla\Firefox\Profiles\8loakqo3.default\bookmarks.html")Blue Text Is the Varible For %systemdrive% Can Be left In Or Taken outOf the scriptSave as, WHATEVER.vbs Dim Act, ApData, Fso, Moz, NewMoz Set Act = CreateObject("Wscript.shell") Set Fso = CreateObject("Scripting.FileSystemObject") ApData = Act.ExpandEnvironmentStrings("%APPDATA%") Sd = Act.ExpandEnvironmentStrings("%Systemdrive%")' Moz = (ApData & "Mozilla\Firefox\Profiles\8loakqo3.default\bookmarks.html")' NewMoz = ("I:\Firefox bookmarks\script test\bookmarks.html") Moz = ("C:\TestMe.txt") NewMoz = (SD & "\Testme.txt") If Fso.FileExists(Moz) Then If Not Fso.FileExists(NewMoz) Then Fso.CopyFile(Moz),(NewMoz) Else' If Fso.FileExists(NewMoz) Then' Fso.CopyFile(Moz),("I:\Firefox bookmarks\script test\BookMarkBack.html") If Fso.FileExists(NewMoz) Then Fso.CopyFile(Moz),(SD & "\TestMeBack.txt") End If End If Else Act.Popup "Cannot Find This File" & vbCrLf & Moz, 5, "Error Missing", 0 + 32 End IfI added a array so it is easier to editRe-Edit Of The Above Code, Use The Above Color Code Part To Edit. Place The Location In Here MozDir = ("I:\Firefox bookmarks\script test") Dim Act, ApData, Fso, MozDir, Moz Set Act = CreateObject("Wscript.shell") Set Fso = CreateObject("Scripting.FileSystemObject") ApData = Act.ExpandEnvironmentStrings("%APPDATA%") Sd = Act.ExpandEnvironmentStrings("%Systemdrive%") MozDir = ("I:\Firefox bookmarks\script test")' Moz = Array((ApData & "Mozilla\Firefox\Profiles\8loakqo3.default\bookmarks.html"),_' (MozDir & "\bookmarksBak.html"),(MozDir & "\bookmarksBak1.html")) Moz = Array("C:\TestMe.txt",(SD & "\Testme.txt"),(SD & "\TestmeBak.txt")) If Fso.FileExists(Moz(0)) Then If Not Fso.FileExists(Moz(1)) Then Fso.CopyFile(Moz(0)),(Moz(1)) Else If Fso.FileExists(Moz(1)) Then Fso.CopyFile(Moz(1)),(Moz(2)) Act.Popup "File Was There And A" & vbCrLf & "New Name Was Applied" &_ vbCrLf & Moz(2), 5, "Error File There 1", 0 + 32 End If End If Else Act.Popup "Cannot Find This File" & vbCrLf & Moz(0), 5, "Error Missing", 0 + 32 End IfNo Rename Just Copy Dim Act, ApData, Fso, MozDir, Moz Set Act = CreateObject("Wscript.shell") Set Fso = CreateObject("Scripting.FileSystemObject") ApData = Act.ExpandEnvironmentStrings("%APPDATA%") Sd = Act.ExpandEnvironmentStrings("%Systemdrive%") MozDir = ("I:\Firefox bookmarks\script test")' Moz = Array((ApData & "Mozilla\Firefox\Profiles\8loakqo3.default\bookmarks.html"),_' (MozDir & "\bookmarksBak.html")) Moz = Array("C:\TestMe.txt",(SD & "\Testme.txt")) If Fso.FileExists(Moz(0)) Then Fso.CopyFile(Moz(0)),(Moz(1)) Else Act.Popup "Cannot Find This File" & vbCrLf & Moz(0), 5, "Error Missing", 0 + 32 End If Edited August 24, 2005 by gunsmokingman
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now