エントリーの編集
エントリーの編集は全ユーザーに共通の機能です。
必ずガイドラインを一読の上ご利用ください。
ファイル名の変更・ファイルのコピー・移動・削除 | Ruby入門 - Worth Living
記事へのコメント0件
- 注目コメント
- 新着コメント
このエントリーにコメントしてみましょう。
注目コメント算出アルゴリズムの一部にLINEヤフー株式会社の「建設的コメント順位付けモデルAPI」を使用しています
- バナー広告なし
- ミュート機能あり
- ダークモード搭載
関連記事
ファイル名の変更・ファイルのコピー・移動・削除 | Ruby入門 - Worth Living
File.rename("text1.dat", "text1_new.dat") File.rename("text2.dat", "child/text2.dat") # ディレク... File.rename("text1.dat", "text1_new.dat") File.rename("text2.dat", "child/text2.dat") # ディレクトリ移動 File.delete("text3.dat") # ファイルのコピー・メソッド定義 def copy(from ,to) open(from){|input| open(to, "w"){|output| output.write(input.read) } } end copy("text4.dat", "child/text4.dat") require "fileutils" FileUtils.cp("text5.dat", "text5_new.dat") # コピー FileUtils.mv("text5.dat", "child/text5.dat") # 移動