[過去ログ]
【.cmd】 バッチファイルスクリプト %14 【.bat】 (1002レス)
【.cmd】 バッチファイルスクリプト %14 【.bat】 http://mevius.5ch.net/test/read.cgi/tech/1597442426/
上
下
前次
1-
新
通常表示
512バイト分割
レス栞
抽出解除
必死チェッカー(本家)
(べ)
自ID
レス栞
あぼーん
このスレッドは過去ログ倉庫に格納されています。
次スレ検索
歴削→次スレ
栞削→次スレ
過去ログメニュー
763: デフォルトの名無しさん [sage] 2022/04/27(水) 18:14:04.80 ID:pviHRewB >>757 Ruby で書いてみた。 DryRun なので、実際にはファイルは削除されません require 'fileutils' # 絶対パスのディレクトリ名の後ろに、* を付けること! # . で始まる、隠し directory, file を除く dir_path = "C:/Users/Owner/Documents/test/*" # そのディレクトリ内の全てのファイルパス・更新時刻を取得する。 # [ ファイルパス, 更新時刻 ]の配列の配列を戻す def collect_filepaths_and_mtime( dir_path ) Dir.glob( dir_path ) .select { |full_path| File.file?( full_path ) } # ファイルのみ .map { |full_path| [ full_path, File.stat( full_path ).mtime ] } # [ ファイルパス, 更新時刻 ] end temp_ary = collect_filepaths_and_mtime( dir_path ) if temp_ary.length >= 10 temp_ary.sort_by! { |ary| ary[ 1 ] } # 更新時刻の古い順でソート # p temp_ary FileUtils::DryRun.remove( temp_ary.first[ 0 ] ) # 削除 else puts "ファイル数は#{ temp_ary.length } です。処理するファイルはありません!" end http://mevius.5ch.net/test/read.cgi/tech/1597442426/763
メモ帳
(0/65535文字)
上
下
前次
1-
新
書
関
写
板
覧
索
設
栞
歴
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
AAサムネイル
Google検索
Wikipedia
ぬこの手
ぬこTOP
0.036s