I used a combination of batch & AutoHotkey:
- Open Thunderbird session.json file at:
%AppData%\Thunderbird\Profiles\[email protected]\session.json
(REPLACE YOUR_MAIL).
- Exit Thunderbird.
- The
folderURI
is saved in session.json.
- Make the files below and copy "thunderbird.bat" & "Thunderbird Open Specific Folder.ahk" to "
C:\Windows\System32\
".
thunderbird.bat accepts 2 args, -mail
& folderName
Thunderbird Open Specific Folder.ahk accepts 1 arg, folderName
which is passed on from the thunderbird.bat
(REPLACE YOUR_MAIL).
5. Open cmd & type for ex: thunderbird -mail Inbox
.
The only downside is you have to close Thunderbird (not minimize to tray, but File > Exit) in order for it to open specific folder.
thunderbird.bat
@echo off
rem Check if the first parameter is "-mail"
if "%1"=="-mail" (
rem Check if the second parameter is "Inbox"
if "%~2"=="Inbox" (
rem Run the AutoHotkey script for Inbox
start "" /b "Thunderbird Open Specific Folder.ahk" Inbox
exit /b
)
rem Check if the second parameter is "Drafts"
if "%~2"=="Drafts" (
rem Run the AutoHotkey script for Drafts
start "" /b "Thunderbird Open Specific Folder.ahk" Drafts
exit /b
)
rem Check if the second parameter is "Templates"
if "%~2"=="Templates" (
rem Run the AutoHotkey script for Templates
start "" /b "Thunderbird Open Specific Folder.ahk" Templates
exit /b
)
rem Check if the second parameter is "Trash"
if "%~2"=="Trash" (
rem Run the AutoHotkey script for Trash
start "" /b "Thunderbird Open Specific Folder.ahk" Trash
exit /b
)
rem Check if the second parameter is "Gmail Drafts"
if "%~2"=="Gmail Drafts" (
rem Run the AutoHotkey script for Gmail Drafts
start "" /b "Thunderbird Open Specific Folder.ahk" "Gmail Drafts"
exit /b
)
rem Check if the second parameter is "Sent Mail"
if "%~2"=="Sent Mail" (
rem Run the AutoHotkey script for Sent Mail
start "" /b "Thunderbird Open Specific Folder.ahk" "Sent Mail"
exit /b
)
rem Check if the second parameter is "All Mail"
if "%~2"=="All Mail" (
rem Run the AutoHotkey script for All Mail
start "" /b "Thunderbird Open Specific Folder.ahk" "All Mail"
exit /b
)
rem Check if the second parameter is "Spam"
if "%~2"=="Spam" (
rem Run the AutoHotkey script for Spam
start "" /b "Thunderbird Open Specific Folder.ahk" Spam
exit /b
)
rem Check if the second parameter is "Gmail Trash"
if "%~2"=="Gmail Trash" (
rem Run the AutoHotkey script for Gmail Trash
start "" /b "Thunderbird Open Specific Folder.ahk" Gmail Trash
exit /b
)
)
rem If the conditions are not met, display a message
echo Invalid parameters. Usage: %0 -mail "FolderName"
Thunderbird Open Specific Folder.ahk
#NoEnv
SetWorkingDir %A_ScriptDir%
#Warn
CoordMode, Mouse, Window
SendMode Input
#SingleInstance Force
SetTitleMatchMode 2
SetTitleMatchMode Fast
DetectHiddenWindows Off
DetectHiddenText On
#WinActivateForce
#NoTrayIcon
SetControlDelay 1
SetWinDelay 0
SetKeyDelay -1
SetMouseDelay -1
SetBatchLines -1
#Persistent
#MaxThreadsPerHotkey 2
ThunderbirdOpenSpecificFolder:
FileCopy, %A_AppData%\Thunderbird\Profiles\[email protected]\session.json, %A_AppData%\Thunderbird\Profiles\[email protected]\session.json.bak, 1 ; session.json > session.json.bak
RunWait, cmd /c cd /d "`%APPDATA`%\Thunderbird\Profiles\[email protected]\" && jq . session.json > sessionPretty.json, , Hide ; sessionPretty.json
FileRead, session, %A_AppData%\Thunderbird\Profiles\[email protected]\sessionPretty.json ; sessionPretty.json
folder := A_Args[1] ; folder
/*
MsgBox, 262144, , "%folder%" ; folder
*/
If (folder = "Inbox") ; IF folder = Inbox
{
session := RegExReplace(session, """folderURI.*""", """folderURI"": ""imap://YOUR_MAIL%[email protected]/INBOX""") ; folder = Inbox
}
Else If (folder = "Drafts") ; IF folder = Drafts
{
session := RegExReplace(session, """folderURI.*""", """folderURI"": ""imap://YOUR_MAIL%[email protected]/Drafts""") ; folder = Drafts
}
Else If (folder = "Templates") ; IF folder = Templates
{
session := RegExReplace(session, """folderURI.*""", """folderURI"": ""imap://YOUR_MAIL%[email protected]/Templates""") ; folder = Templates
}
Else If (folder = "Trash") ; IF folder = Trash
{
session := RegExReplace(session, """folderURI.*""", """folderURI"": ""imap://YOUR_MAIL%[email protected]/Trash""") ; folder = Trash
}
Else If (folder = "Gmail Drafts") ; IF folder = Gmail Drafts
{
session := RegExReplace(session, """folderURI.*""", """folderURI"": ""imap://YOUR_MAIL%[email protected]/[Gmail]/Drafts""") ; folder = Gmail Drafts
}
Else If (folder = "Sent Mail") ; IF folder = Sent Mail
{
session := RegExReplace(session, """folderURI.*""", """folderURI"": ""imap://YOUR_MAIL%[email protected]/[Gmail]/Sent Mail""") ; folder = Sent Mail
}
Else If (folder = "All Mail") ; IF folder = All Mail
{
session := RegExReplace(session, """folderURI.*""", """folderURI"": ""imap://YOUR_MAIL%[email protected]/[Gmail]/All Mail""") ; folder = All Mail
}
Else If (folder = "Spam") ; IF folder = Spam
{
session := RegExReplace(session, """folderURI.*""", """folderURI"": ""imap://YOUR_MAIL%[email protected]/[Gmail]/Spam""") ; folder = Spam
}
Else If (folder = "Gmail Trash") ; IF folder = Gmail Trash
{
session := RegExReplace(session, """folderURI.*""", """folderURI"": ""imap://YOUR_MAIL%[email protected]/[Gmail]/Trash""") ; folder = Gmail Trash
}
FileDelete, %A_AppData%\Thunderbird\Profiles\[email protected]\sessionPretty.json ; sessionPretty.json
FileDelete, %A_AppData%\Thunderbird\Profiles\[email protected]\session.json ; session.json
FileAppend, %session%, %A_AppData%\Thunderbird\Profiles\[email protected]\session.json ; session.json
Run, thunderbird ; thunderbird
ExitApp ; ExitApp
Return
URLS.txt
imap://YOUR_MAIL%[email protected]/INBOX
imap://YOUR_MAIL%[email protected]/Drafts
imap://YOUR_MAIL%[email protected]/Templates
imap://YOUR_MAIL%[email protected]/Trash
imap://YOUR_MAIL%[email protected]/[Gmail]/Drafts
imap://YOUR_MAIL%[email protected]/[Gmail]/Sent Mail
imap://YOUR_MAIL%[email protected]/[Gmail]/All Mail
imap://YOUR_MAIL%[email protected]/[Gmail]/Spam
imap://YOUR_MAIL%[email protected]/[Gmail]/Trash
(REPLACE YOUR_MAIL).
Cli Commands.txt
thunderbird -mail Inbox
thunderbird -mail Drafts
thunderbird -mail Templates
thunderbird -mail Trash
thunderbird -mail "Gmail Drafts"
thunderbird -mail "Sent Mail"
thunderbird -mail "All Mail"
thunderbird -mail Spam
thunderbird -mail "Gmail Trash"
thunderbird.exe label:<LABEL>
or any variation did not work. I'm affaid, the links did not provide any usefull information. Still a good idea tho.