Skip to content

Instantly share code, notes, and snippets.

@hatappo
Forked from 544/ReNameOfindXargs.sh
Last active November 18, 2021 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hatappo/316ee920b5c10fe9785260f3bec2ba0f to your computer and use it in GitHub Desktop.
Save hatappo/316ee920b5c10fe9785260f3bec2ba0f to your computer and use it in GitHub Desktop.
findとxargsでファイル名変更、そしてファイル名を戻す。
# カレントディレクトリ直下のマークダウンのファイルすべてに対して、ファイル名の末尾に '.org' を付与する
find ./ -type f -maxdepth 1 -name "*.md" | xargs -I% mv % %.org
# 上とまったく逆の操作。 末尾の '.org' を取り除く。
find ./ -type f -maxdepth 1 -name "*.md.ignore" | sed 's/\.ignore$//' | xargs -I% mv %.org %
# いったん、ファイル名を退避して、ことが終わったらもとに戻す、とかのときに便利。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment