Skip to content

Instantly share code, notes, and snippets.

@ktkr3d
Created August 22, 2020 06:43
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 ktkr3d/ddfd574f4a8e956dafa667bd182cdab8 to your computer and use it in GitHub Desktop.
Save ktkr3d/ddfd574f4a8e956dafa667bd182cdab8 to your computer and use it in GitHub Desktop.
ファイルのタイムスタンプ(YYYYMMDD-hhmmss)をファイル名の先頭に追加する。
#!/bin/bash
mkdir -p renamed
while read -d $'\0' file; do
file=`echo "${file}" | sed 's!^.*/!!'`
timestamp=`date "+%Y%m%d-%H%M%S" -r "${file}"`
mv "${file}" ./renamed/${timestamp}_"${file}"
done < <(find . -mindepth 1 -maxdepth 1 -type f -print0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment