9
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

iPhoneシミュレータのスクリーンショットを任意の場所に保存する

Last updated at Posted at 2015-03-13

ご存じの通り、iPhone/iPadのシミュレータのスクリーンショット(コマンド + s)はデスクトップに保存される。
頻繁にスクリーンショットを保存するとデスクトップが散らかる&削除がめんどくさいので、Automator + Rubyで、任意の場所に保存するようにしてみた。

やり方

1. Automatorを起動 > フォルダアクションを選択

スクリーンショット 2015-03-12 21.33.39.png

2. フォルダアクションの項目をDesktopに変更する

スクリーンショット_2015-03-12_21_34_19.png

3. アクションからシェルスクリプトを実行を選択する

スクリーンショット 2015-03-12 21.35.07.png

4. シェルの項目を/usr/bin/rubyに変更 > 下記のプログラムをコピペして適当な名前で保存

require 'fileutils'

fromDir = ENV['HOME'] + '/Desktop'
toDir = ENV['HOME'] + '/Desktop/iOSSimulatorScreenShot' #保存先を変えたい場合はこの部分を変更する

FileUtils.mkdir_p(toDir) unless FileTest.exist?(toDir)

FileUtils.mv(Dir.glob(fromDir + '/iOS\ Simulator\ Screen\ Shot*.png'), toDir);

5. Finderからデスクトップを右クリックしフォルダアクションを設定を選択

スクリーンショット_2015-03-12_21_36_51.png

6. フォルダアクション設定で保存したスクリプトを選択

スクリーンショット 2015-03-12 21.55.16.png

7. 実行してみる

PCを再起動して、シミュレータでスクリーンショットを保存すると、デスクトップにiOSSimulatorScreenShotというフォルダが作成され、そこにどんどん保存される。不要になったらフォルダ毎削除する。再度保存してもフォルダが自動的に作成されて保存されていく。

9
10
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?