スレ立てるまでもない質問はここで 159匹目at TECHスレ立てるまでもない質問はここで 159匹目 - 暇つぶし2ch■コピペモード□スレを通常表示□オプションモード□このスレッドのURL■項目テキスト200:195 22/02/24 21:57:06.88 82W7j8jp.net # dest_dir の直下には、1つだけ解凍されたディレクトリがあると想定する decomp_root_path = dest_dir.children[0] #=> <Pathname: C:/Users/Owner/Documents/data/20220224_211030/z> decomp_root_dir = decomp_root_path.basename.to_s # ディレクトリ名。z # 末尾に、_out を加えた、ディレクトリ名。z_out out_dir = decomp_root_dir + "_out" # decomp_root_path の末尾に、_out を加えたパス out_root_path = dest_dir + out_dir #=> <Pathname: C:/Users/Owner/Documents/data/20220224_211030/z_out> out_root_path.mkdir( ) # ディレクトリを作る print "\n#{ out_root_path.to_s } フォルダを作りました\n\n" # 絶対パスのディレクトリ名の後ろに、* を付けること! # . で始まる、隠し directory, file を除く decomp_root_path.glob( "**/*.{png,jpg,jpeg,gif,bmp,webp}" ) do |full_path| # decomp_root_dirの部分だけを、_out を加えて、out_dir に変えたもの out_full_path = out_root_path + full_path.relative_path_from( decomp_root_path ) dir = out_full_path.parent # ディレクトリ # ディレクトリが存在しなければ、親ディレクトリも含めて作る。mkdir_p dir.mkpath unless dir.directory? # ここに、各画像ファイルの変換処理を書く! end 次へ続く 次ページ最新レス表示レスジャンプ類似スレ一覧スレッドの検索話題のニュースおまかせリストオプションしおりを挟むスレッドに書込スレッドの一覧暇つぶし2ch