Convert numbers and spaces from full-width (double-byte) to half-width (single-byte) #
Within filenames (using Bash, Perl, and Unicode-Japanese-0.47):
- $sudo perl -MCPAN -e shell
- cpan> install Unicode::Japanese
- Save the following script (adapted largely from togdon's example) as full2half.sh and make it executable (chmod u+x):
#!/bin/bash
for file in *;do
newfile=$(echo $file | perl -MUnicode::Japanese -e'print Unicode::Japanese->new(<>)->z2h->get;')
test "$file" != "$newfile" && mv "$file" "$newfile"
done
- cd to desired directory and run script:
$ /path/to/full2half.sh
Within file contents (using OpenOffice.org):
- Tools > Options... (in OS X it's OpenOffice.org > Preferences...)
- Language Settings > Languages > check "Enabled for Asian languages" > OK
- Highlight text > Format > Change Case > Full-width or Half-width
/nix | Jan 02, 2010
Subscribe or visit the archives.