Skip to content

Instantly share code, notes, and snippets.

@chikoski
Created February 22, 2013 00:20
Show Gist options
  • Save chikoski/5009728 to your computer and use it in GitHub Desktop.
Save chikoski/5009728 to your computer and use it in GitHub Desktop.
ディレクトリ内のファイルから、次のファイルの名前にする数字をみつけるスニペット。 連番を振るときに便利。
Dir::entries(DATA_DIR).map{|i|
File.basename(i).gsub(/^([^\.]+).*/, "\\1").to_i
}.sort.last + 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment