You are not logged in.

#1 2011-02-18 01:43:59

m45kop!
Member
Registered: 2010-11-24
Posts: 6

Decoding MIME style filenames using bash

I have files which names contains one, some or all of the strings "=E5", "=E4", "=D6". They actually correspond to "å", "ä" and "ö", but they're converted in the fashion of MIME encoding. I've been looking around for a solution to converting them back to what they're supposed to be, but when I try using various rename scripts and snippets of other code they always seem to fail somehow. I just don't know how to handle the equality sign when scripting in bash. Help is appreciated!

Offline

#2 2011-02-18 11:13:20

tlvb
Member
From: Sweden
Registered: 2008-10-06
Posts: 297
Website

Re: Decoding MIME style filenames using bash

Try this:

find . -regex '.*=\(E4\|E5\|D6\).*'|sed -n `echo -e "p;s/=E5/\xc3\xa5/g;s/=E4/\xc3\xa4/g;s/=D6/\xc3\xb6/g;p"`|xargs -n2 mv

...on some dummies to begin with of course.

This will probably only work if your system accepts unicode where neccesary...

Last edited by tlvb (2011-02-18 11:48:30)


I need a sorted list of all random numbers, so that I can retrieve a suitable one later with a binary search instead of having to iterate through the generation process every time.

Offline

#3 2011-02-20 20:02:21

m45kop!
Member
Registered: 2010-11-24
Posts: 6

Re: Decoding MIME style filenames using bash

Your script/code worked as intended. Now the fun part - actually understanding what I just pasted into my terminal! Thank you so much for the help!

Offline

Board footer

Powered by FluxBB