MSFN Forum: Need a .cmd or .bat for exporting Firefox bookmark - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Need a .cmd or .bat for exporting Firefox bookmark I can't write the script - need help Rate Topic: -----

#1 User is offline   Wedge1 

  • Junior
  • Pip
  • Group: Members
  • Posts: 67
  • Joined: 17-October 04

Posted 23 August 2005 - 01:29 PM

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


#2 User is offline   dman 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 717
  • Joined: 01-February 05

Posted 23 August 2005 - 01:41 PM

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.pa...om/index-en.htm

This post has been edited by dman: 23 August 2005 - 01:51 PM


#3 User is offline   Wedge1 

  • Junior
  • Pip
  • Group: Members
  • Posts: 67
  • Joined: 17-October 04

Posted 23 August 2005 - 04:06 PM

@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?

#4 User is offline   dman 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 717
  • Joined: 01-February 05

Posted 23 August 2005 - 04:09 PM

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"

This post has been edited by dman: 23 August 2005 - 04:13 PM


#5 User is online   gunsmokingman 

  • MSFN Addict
  • Group: Super Moderator
  • Posts: 1,991
  • Joined: 02-August 03
  • OS:none specified
  • Country: Country Flag

Posted 23 August 2005 - 04:44 PM

Here is the same cmd using the "%USERPROFILE% varible

Quote

Echo Off && Copy /y "%USERPROFILE%\Application Data\Mozilla\Firefox\Profiles\8loakqo3.default\bookmarks.html" "I:\Firefox bookmarks\script test\bookmarks.html"


#6 User is offline   Wedge1 

  • Junior
  • Pip
  • Group: Members
  • Posts: 67
  • Joined: 17-October 04

Posted 23 August 2005 - 04:49 PM

Got it. THanks Posted Image :) Posted Image

#7 User is offline   Wedge1 

  • Junior
  • Pip
  • Group: Members
  • Posts: 67
  • Joined: 17-October 04

Posted 23 August 2005 - 04:53 PM

gunsmokingman, on Aug 23 2005, 04:44 PM, said:

Here is the same cmd using the "%USERPROFILE% varible

Quote

Echo 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?

#8 User is offline   dman 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 717
  • Joined: 01-February 05

Posted 23 August 2005 - 05:10 PM

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.

#9 User is offline   Wedge1 

  • Junior
  • Pip
  • Group: Members
  • Posts: 67
  • Joined: 17-October 04

Posted 23 August 2005 - 05:15 PM

dman, on Aug 23 2005, 05:10 PM, said:

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.

#10 User is offline   dman 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 717
  • Joined: 01-February 05

Posted 23 August 2005 - 05:19 PM

:thumbup

#11 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,117
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 23 August 2005 - 08:32 PM

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.

#12 User is offline   dman 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 717
  • Joined: 01-February 05

Posted 23 August 2005 - 08:41 PM

Nice one, "Wise Owl" (finally got it when you changed your avatar).

#13 User is online   gunsmokingman 

  • MSFN Addict
  • Group: Super Moderator
  • Posts: 1,991
  • Joined: 02-August 03
  • OS:none specified
  • Country: Country Flag

Posted 23 August 2005 - 09:56 PM

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

Quote

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

Quote

  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

Quote

  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

This post has been edited by gunsmokingman: 23 August 2005 - 11:12 PM


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy