#contents * シェルスクリプト置き場 [#q18d5819] ** 再帰処理&拡張子テスト [#pb57fcad] CURRENT_PATH=`pwd` OUTFILE=${CURRENT_PATH}/out.html echo $OUTFILE Seek(){ for ELEM in * ; do if [ -f "$ELEM" ] ; then if [ `echo "$ELEM" | grep ".html$"` ] ; then #echo "$ELEM" cat "$ELEM" >> "$OUTFILE" fi fi if [ -d "$ELEM" ] ; then (cd "$ELEM";Seek;) fi done } Seek; # -*- coding: japanese-cp932 -*- ## windwos cmd 用rubyスクリプト ## gif, jpgはCURRENT_PATHへコピー ## Img...で始まるディレクトリは,ディレクトリごとCURERNT_PATHへコピー ## カレントディレクトリのディレクトリカタログ top_dir_entries= Dir::entries("./"); commands= []; for d in top_dir_entries ## ディレクトリだったら if (File::ftype(d) == "directory") child_dir_entries= Dir::entries(d); for d2 in child_dir_entries if ((File::ftype(d + "/" + d2) == "directory") && (d2 =~ /^Img[A-Z]\d+$/)) p "xcopy /e /i ./#{d}/#{d2} ./#{d2}"; `xcopy /e /i .\\#{d}\\#{d2} .\\#{d2}`; ## commands.push("xcopy /e /i Chap0 copy-of-Chap0"); elsif((File::ftype(d + "/" + d2) == "file") && (d2 =~ /\.(jpg|gif)$/)) ## p "copy .\\#{d}\\#{d2} .\\#{d2}"; ## `copy .\\#{d}\\#{d2} .\\#{d2}`; end end end end ## Img...という名前のディレクトリなら再帰コピー ## 画像ファイルならコピー ## `xcopy /e /i Chap0 copy-of-Chap0`;