Skip to content

Instantly share code, notes, and snippets.

@seventhsense
Created July 18, 2018 21:00
Show Gist options
  • Save seventhsense/a7558e32572dbbd6939c913b5456a0f2 to your computer and use it in GitHub Desktop.
Save seventhsense/a7558e32572dbbd6939c913b5456a0f2 to your computer and use it in GitHub Desktop.
日本語ファイル名のmdをローマ字でハイフン分かち書きに変換するスクリプト(破壊的)要nkf kakasi
#!/bin/bash
dir=`pwd`
list=`find ${dir} -type f`
for file in $list; do
filename=`basename $file`
ext=${filename##*.}
if [[ $ext == "md" ]]; then
echo $filename
basename=${filename%.*}
names=`echo $basename | nkf -e | kakasi -w | kakasi -Ja -Ha -Ka -Ea`
# echo $basename | nkf -e | kakasi -w | kakasi -Ja -Ha -Ka -Ea
new_basename=${names// /-}
mv $filename "${new_basename}.md"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment