Jump to content

Recommended Posts

Posted

Hi,

I use ThunderBird Portable and I have a copy on my computer but I also regularly update the copies on my laptop and personal computer but every time I do this i have to update the paths of where configuration files exist otherwise it breaks.

I'm looking for a better way to cycle through every single file and automatically update the paths because whenever a new Thunderbird update comes out there is always some files that I need to update that aren't in my list....

The default installation folder is listed in multiple ways throughout the files from:

C:\Users\Hyflex\Downloads\New E-Mail\
C:\\Users\\Hyflex\\Downloads\\New E-Mail\\
C:\\\Users\\\Hyflex\\\Downloads\\\New E-Mail\\\
C:\\\\\\\\Users\\\\\\\\Hyflex\\\\\\\\Downloads\\\\\\\\New E-Mail\\\\\\\\

C:/Users/Hyflex/Downloads/New E-Mail/
C://Users//Hyflex//Downloads//New E-Mail//
C:///Users///Hyflex///Downloads///New E-Mail///
C:////////Users////////Hyflex////////Downloads////////New E-Mail////////


I need to keep their same structure throughout the files...

Currently I have a little autoit script that replaces my desktop path with the new path:

$SZFILE = @ScriptDir & "\ThunderbirdPortable\Data\settings\ThunderbirdPortableSettings.ini"
$SZTEXT = FileRead($SZFILE, FileGetSize($SZFILE))
$SZTEXT = StringReplace($SZTEXT, "C:\Users\Hyflex\Downloads\New E-Mail\", @ScriptDir & "\", 0, 1)
FileDelete($SZFILE)
FileWrite($SZFILE, $SZTEXT)

$SZFILE = @ScriptDir & "\ThunderbirdPortable\Data\profile\compatibility.ini"
$SZTEXT = FileRead($SZFILE, FileGetSize($SZFILE))
$SZTEXT = StringReplace($SZTEXT, "C:\Users\Hyflex\Downloads\New E-Mail\", @ScriptDir & "\", 0, 1)
FileDelete($SZFILE)
FileWrite($SZFILE, $SZTEXT)

$SZFILE = @ScriptDir & "\ThunderbirdPortable\Data\profile\extensions.ini"
$SZTEXT = FileRead($SZFILE, FileGetSize($SZFILE))
$SZTEXT = StringReplace($SZTEXT, "C:\Users\Hyflex\Downloads\New E-Mail\", @ScriptDir & "\", 0, 1)
FileDelete($SZFILE)
FileWrite($SZFILE, $SZTEXT)

$SZFILE = @ScriptDir & "\ThunderbirdPortable\Data\profile\extensions.json"
$SZTEXT = FileRead($SZFILE, FileGetSize($SZFILE))
$SZTEXT1 = StringRegExpReplace(@ScriptDir & "\", "\\", "\\\\")
$SZTEXT = StringReplace($SZTEXT, "C:\\Users\\Hyflex\\Downloads\\New E-Mail\\", $SZTEXT1, 0, 1)
FileDelete($SZFILE)
FileWrite($SZFILE, $SZTEXT)

$SZFILE = @ScriptDir & "\ThunderbirdPortable\Data\profile\prefs.js"
$SZTEXT = FileRead($SZFILE, FileGetSize($SZFILE))
$SZTEXT1 = StringRegExpReplace(@ScriptDir & "\", "\\", "\\\\")
$SZTEXT = StringReplace($SZTEXT, "C:\\Users\\Hyflex\\Downloads\\New E-Mail\\", $SZTEXT1, 0, 1)
FileDelete($SZFILE)
FileWrite($SZFILE, $SZTEXT)

$SZFILE = @ScriptDir & "\ThunderbirdPortable\Data\profile\prefs.js"
$SZTEXT = FileRead($SZFILE, FileGetSize($SZFILE))
$SZTEXT1 = StringRegExpReplace(@ScriptDir & "\", "\\", "\\\\\\\\")
$SZTEXT = StringReplace($SZTEXT, "C:\\\\Users\\\\Hyflex\\\\Downloads\\\\New E-Mail\\\\", $SZTEXT1, 0, 1)
FileDelete($SZFILE)
FileWrite($SZFILE, $SZTEXT)

$SZFILE = @ScriptDir & "\ThunderbirdPortable\Data\profile\panacea.dat"
$SZTEXT = FileRead($SZFILE, FileGetSize($SZFILE))
$SZTEXT1 = StringRegExpReplace(@ScriptDir & "\", "\\", "\\\\")
$SZTEXT = StringReplace($SZTEXT, "C:\\Users\\Hyflex\\Downloads\\New E-Mail\\", $SZTEXT1, 0, 1)
FileDelete($SZFILE)
FileWrite($SZFILE, $SZTEXT)

$SZFILE = @ScriptDir & "\ThunderbirdPortable\Data\profile\search.json"
$SZTEXT = FileRead($SZFILE, FileGetSize($SZFILE))
$SZTEXT1 = StringRegExpReplace(@ScriptDir & "\", "\\", "\\\\")
$SZTEXT = StringReplace($SZTEXT, "C:\\Users\\Hyflex\\Downloads\\New E-Mail\\", $SZTEXT1, 0, 1)
FileDelete($SZFILE)
FileWrite($SZFILE, $SZTEXT)

$SZFILE = @ScriptDir & "\ThunderbirdPortable\Data\profile\pluginreg.dat"
$SZTEXT = FileRead($SZFILE, FileGetSize($SZFILE))
$SZTEXT = StringReplace($SZTEXT, "C:\Users\Hyflex\AppData\Roaming\", @AppDataDir & "\", 0, 1)
FileDelete($SZFILE)
FileWrite($SZFILE, $SZTEXT)

$SZFILE = @ScriptDir & "\ThunderbirdPortable\App\thunderbird\uninstall\uninstall.update"
$SZTEXT = FileRead($SZFILE, FileGetSize($SZFILE))
$SZTEXT = StringReplace($SZTEXT, "C:\Users\Hyflex\AppData\Local\", @LocalAppDataDir & "\", 0, 1)
FileDelete($SZFILE)
FileWrite($SZFILE, $SZTEXT)

$SZFILE = @ScriptDir & "\ThunderbirdPortable\App\thunderbird\uninstall\uninstall.update"
$SZTEXT = FileRead($SZFILE, FileGetSize($SZFILE))
$SZTEXT = StringReplace($SZTEXT, "C:\Users\Hyflex\Downloads\New E-Mail\", @ScriptDir & "\", 0, 1)
FileDelete($SZFILE)
FileWrite($SZFILE, $SZTEXT)

$SZFILE = @ScriptDir & "\ThunderbirdPortable\Data\profile\startupCache\startupCache.4.little"
$SZTEXT = FileRead($SZFILE, FileGetSize($SZFILE))
$SZTEXT1 = StringRegExpReplace(@ScriptDir & "\", "\\", "/")
$SZTEXT1 = StringRegExpReplace($SZTEXT1, " ", "%20")
$SZTEXT = StringReplace($SZTEXT, "C:/Users/Hyflex/Downloads/New%20EMail/", $SZTEXT1, 0, 1)
FileDelete($SZFILE)
FileWrite($SZFILE, $SZTEXT)


Anyone have any ideas how I can improve this? I'd much appreciate some help!

Posted

i'm using the portable version of Thunderbird, making sync between devices very simple (typically between my desktop and a thumb drive).

for replacing strings in multiple files, i've been using fnr.exe (the command line). i just revisited it to see if there are any updates, it took a while but i found it was moved to this site.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Posted (edited)

working backwards, looks like you just need to replace the dividers.  Can probably run them all through the same func.

#include<array.au3>

local $aTest[6]=["C:\test1\test2\test3" , "C:\\test1\\test2\\test3" , "C:\\\test1\\\\test2\\\\test3" , "C:/test1/test2/test3" , "C:///test1///test2///test3" , "C:////test1////test2/////test3" ]

$aScriptDir = stringsplit(@ScriptDir , "\" , 2)

For $i = 0 to ubound($aTest) - 1
    $sDiv = stringregexp($aTest[$i] , "\w:(.*?)\w" , 3)[0]
    $aTest[$i] = ""
    For $j = 0 to ubound($aScriptDir) - 1
       $aTest[$i] &= $aScriptDir[$j] & $sDiv
    Next
Next

_ArrayDisplay($aTest)

try 2, same result (hopefully) but a little more portable.  probably still needs cleaning to verify the drive letter and catch edge cases, but definitely doable.

#include<array.au3>

local $aTest[6]=["C:\test1\test2\test3" , "C:\\test1\\test2\\test3" , "C:\\\test1\\\\test2\\\\test3" , "C:/test1/test2/test3" , "C:///test1///test2///test3" , "C:////test1////test2/////test3" ]

For $i = 0 to ubound($aTest) - 1
    $aTest[$i] = StringReplace(@ScriptDir  , "\" , stringregexp($aTest[$i] , "\w:(.*?)\w"  , 3)[0])
Next

_ArrayDisplay($aTest)

 

Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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...