A few notes:
- Thunderbird apparently doesn't delete saved searches on-disk even after deleting them in the UI, so my IMAP folder for the old server was full of old .msf for searches I wasn't using anymore (so I took this opportunity to not migrate those)
- At some point Thunderbird switched their file naming convention from "Foo%20Bar.msf" to "Foo Bar.msf", so I had some duplicates (one out of date) from whenever that migration happened (probably Thunderbird 2.x -> 3.x?)
- In my case, I have my saved searches at the top-level view, not under Inbox, so they appear at ImapMail/server/saved-search.msf
- The saved search files are small, but contain references to the old hostname that I need to find/replace
- After migrating the .msf files, verifying them in Thunderbird, and exiting, virtualFolders.dat was updated (which explains why editing this file did nothing and just got overwritten)
Here's the command I ran with Thunderbird not running to migrate the saved search .msfs. Apologies for the bad wrapping:
find ImapMail/oldserver/*.msf -size -5k -and -not -name "*%20*" -and -not -name "Trash.msf" -print0 | xargs -0 perl -e 'foreach $path (@ARGV) { $path =~ /.*\/([^\/]+)/; $filename = $1; print "sed 's/oldserver/newserver/g' \"$path\" > \"ImapMail/newserver/$filename\"\n"; }' | sh
Note that the arguments to find are the ones most likely to change in your situation; I had some filters to remove unused-but-not-quite-deleted old saved searches; the filter on size and to ignore Trash.msf is only necessary because I organize my saved searches at the top level with my other non-virtual folders.
I realize there are probably a bajillion ways to do this multifile find/replace and copy, but this method is my preference since it handles escaping of filenames, and I can inspect what is being matched at each point where the commands are coupled by a pipe.
You'd have to replace the oldserver and newserver path arguments in the call to sed and in the input and output paths. Note the Perl regex that effectively does a basename.
I am very much hoping that there will be a UI way of doing this at some point. I realize this is a special case (saved searches associated with a single account moving to a different account by hostname with identical folder structure), though...