Skip to content

Instantly share code, notes, and snippets.

@av-gantimurov
Last active August 5, 2021 00:53
Show Gist options
  • Save av-gantimurov/cccf64e346fc620b2f20eb2ead9596bf to your computer and use it in GitHub Desktop.
Save av-gantimurov/cccf64e346fc620b2f20eb2ead9596bf to your computer and use it in GitHub Desktop.
Fix munpack UTF-8 names in attachments
#!/bin/sh
find . -type f -iname '*X=' | while read name
do
newname=$(echo "$name" | sed 's/[[:print:]]*\/=Xutf-8XBX//I; s/X=XXX=Xutf-8XBX//gI; s/X=$//' | base64 -d )
dir=$(echo $name | sed 's/\/=Xutf-8XBX[A-Za-z0-9X=/+-]\+//I')
mv --verbose "$name" "${dir}/${newname}"
done
@IsaacN72
Copy link

IsaacN72 commented Aug 5, 2021

Thanks both av-gantimurov and gilles0606 for your contributions. Simple, yet effective solutions, much appreciated even years later!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment