Jump to content

Need a .cmd or .bat for exporting Firefox bookmark


Recommended Posts

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 :)

Link to comment
Share on other sites


Really just one command will do it. Something like...

@echo off
copy /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 choosing

note 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 scheduler

you could also try Fab's autobackup for more complete solution...

http://autobackup.parisot-net.com/index-en.htm

Edited by dman
Link to comment
Share on other sites

@echo off
copy /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?

Link to comment
Share on other sites

you need quotes around any path with spaces. sorry, didn't make that clear.

@echo off
copy /Y "C:\Documents and Settings\Owner\Application Data\Mozilla\Firefox\Profiles\8loakqo3.default\bookmarks.html"
"I:\Firefox bookmarks\script test\bookmarks.html"

Edited by dman
Link to comment
Share on other sites

Here is the same cmd using the "%USERPROFILE% varible
Echo Off && Copy /y "%USERPROFILE%\Application Data\Mozilla\Firefox\Profiles\8loakqo3.default\bookmarks.html" "I:\Firefox bookmarks\script test\bookmarks.html"

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 enableextensions
set backupdir=I:\Firefox bookmarks\script test
for /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 :eof

Just change the location for your backups after the equals symbol on the second line

  • Note
    This will not work for those users with more than one firefox profile defined

Just schedule the batch to run with AT or SCHTASKS.

Link to comment
Share on other sites

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 Script

Red Text Is Your File Remove ' from in front of the text

Example

This 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 out

Of the script

Save 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 If

I added a array so it is easier to edit

Re-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 If

No 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 by gunsmokingman
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...