Referencing randomly named folders

Hey there!

I’m writing a generic script that backups Firefox’s bookmarks. Trouble is that FF stores that info in a randomly named profile folder:

~/Library/Application Support/Firefox/Profiles/[somethingrandom].default/bookmarks.html

How would you go about referencing that file?

Thanks a lot,
O

Hi,

try this


set profileFolder to POSIX path of (path to application support folder from user domain) & "Firefox/Profiles/"
set bookmarkFiles to paragraphs of (do shell script "/usr/bin/find " & quoted form of profileFolder & " -name bookmarks.html")

Cool! Thanks!

And how would you reference the profile folder itself?

The first line of the script points to the profile folder, if you want a HFS path, use


set profileFolder to ((path to application support folder from user domain as text) & "Firefox:Profiles:")

Ah.
Sorry for being vague.
I mean the randomly named profile folder (somethingrandom.default) inside the profiles folder.


set profileFolder to ((path to application support folder from user domain as text) & "Firefox:Profiles:")
tell application "Finder" to set defaultFolder to (folder 1 of folder profileFolder whose name ends with "default") as text


Hi olindefelt,

If you want the user to choose which profile bookmarks to backup, you could also read and parse the following configuration file:

/Users/yourname/Library/Application Support/Firefox/profiles.ini

If you open this file with your favorite text editor you can see, that it contains certain key/value-pairs for every profile, including the profile name and the corresponding relative path to the profile folder:

[Profile0] Name=default IsRelative=1 Path=Profiles/42stukvd.default