20/07/05 07:57:11.74 R1IME3L+0.net
>>228
Ruby で作った。
ただし、DryRun なので実際には実行されません!
require 'fileutils'
# 絶対パスのディレクトリ名の後ろに、* を付けること!
# . で始まる、隠し directory, file を除く
glob_pattern = "C:/Users/Owner/Documents/*"
src_dir = File.dirname( glob_pattern ) # ディレクトリパスだけを取り出す
Dir.glob( glob_pattern )
.select { |full_path| File.file?( full_path ) } # ファイルのみ処理する
.each do |full_path| # 1つずつ処理する
dest_path = src_dir + "/" + "2020_" + File.basename( full_path ) # ファイル名
FileUtils::DryRun.move( full_path, dest_path )
end
# mv C:/Users/Owner/Documents/a.txt
# C:/Users/Owner/Documents/2020_a.txt