{"id":790,"date":"2016-12-02T18:03:12","date_gmt":"2016-12-02T23:03:12","guid":{"rendered":"https:\/\/www.devolve.net\/blog\/?p=790"},"modified":"2016-12-02T12:32:08","modified_gmt":"2016-12-02T17:32:08","slug":"rename-iconv","status":"publish","type":"post","link":"https:\/\/www.devolve.local\/rename-iconv\/","title":{"rendered":"Rename and Iconv are like Chocolate and Peanut Butter"},"content":{"rendered":"
The features of iconv<\/strong> are probably built into Perl rename<\/strong> (aka prename<\/strong>), but when I tried the example from the man page, it kept generating an error message. I presume this is due to a missing Perl module. Here’s the error:<\/p>\n So I suppose if we don’t care much about speed then we can just use an external utility like iconv<\/strong> to help convert a whole bunch of crap file names to something a little more universally-digestible. Change to the directory with the unfriendly file names and then run this rename<\/strong> and iconv<\/strong> combo to bulk rename them:<\/p>\n I just renamed over two thousand files with this so I haven’t looked at all of them, but so far it looks like it’s done a great job.<\/p>\nUse of uninitialized value $out_enc in concatenation (.) or string at \/%homebrew%\/bin\/rename line 149.\r\nNo such encoding<\/pre>\n
echo -n \"\/usr\/bin\/iconv -f utf-8 -t ascii\/\/TRANSLIT\" > ~\/bin\/2ascii\r\nchmod +x ~\/bin\/2ascii\r\nrename -P ~\/bin\/2ascii -Xz -e 's\/_(\\W)_\/$1\/g; s\/__+\/_\/g;' *<\/pre>\n