powershelloutlookthunderbirdmaildir

Adding .eml to the end of every filename in multiple folders


So here's the deal:

I been using Thunderbird - it been great but I want to move to Microsoft Outlook. Now because I taken things a little too far, I decided to use maildir for storing my emails. Again it was wonderful but I need to move on.

My plan was to do Thunderbird ->import into mailstore ->export to pst -> import into outlook (or get outlook to open the file).

Now that should be easy enough but the issue is that I need a way to add the ".eml" to the end of every file otherwise mailstore won't import the emails.

I'm running Windows 10 pro x64 and this is what I am doing in powershell:

Get-ChildItem -File -Recurse | % { Rename-Item -Path $_.PSPath -NewName $_.FullName ( $_.Name + ".eml" )}

Now I saw the answer given in https://stackoverflow.com/a/21611922/1129151 but it wasn't what I was after. I also saw http://www.kevinberridge.com/2010/06/powershell-add-extension-to-every-file.html but the issue was that it didn't handle adding the ".eml" recursively.

When I tried to run the above code I get

Rename-Item : A positional parameter cannot be found that accepts argument '1506493412587000.eml'. At line:1 char:36 + ... curse | % { Rename-Item -Path $.PSPath -NewName $.FullName ( $_.Nam ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Rename-Item], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.RenameItemCommand

Could someone please tell me what I need to do to get the ".eml" on?

Thank you :)


Solution

  • So all files have no extension. I have added File parameter which will only retrieve files and not folder, use it if you have any sub folders in your mail folder.

    get-childItem C:\temp\pos\mail\*.* -Recurse -File | rename-item -newname { "$($_.name).eml" }