[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

(DTPtechNote:598) ファイルの修正時間の変更



昔書いたんだけど、どこかにいっちゃって。。。
探すのも面倒だから書き直し。
仕事が早く終わっちゃった時の必携ツール(爆)

property change_time : "1"
property Fluctuation : "1"

on open of theFiles
	tell application "Finder"
		
		--入力
		with timeout of 3600 seconds
			set ANS to display dialog "修正日付を変更します(単位:時間)" default answer change_time buttons {"キャンセル", "変更する", "揺らぎを与える"} default button 3 with icon 1
			set change_time to text returned of ANS
			set change_way to button returned of ANS
			if change_way is "揺らぎを与える" then
				set Fluctuation to text returned of (display dialog "±どれくらい揺らぎを与えますか?(単位:時間)" default answer Fluctuation buttons {"キャンセル", "変更する"} default button 2 with icon 1)
			else
				set Fluctuation to 0
			end if
		end timeout
		try
			set change_time_seconds to (change_time as number) * 3600
			set fluctuation_seconds to (Fluctuation as number) * 3600
		on error errMsg number errNum
			display dialog "半角数字で入力してください" buttons {"キャンセル"}
		end try
		
		--ファイルの変更
		repeat with i in theFiles
			try
				set modification date of i to (modification date of i) + change_time_seconds + (random number from ("-" & fluctuation_seconds) as number to fluctuation_seconds)
			on error errMsg number errNum
				display dialog ((name of i) as Unicode text) & return & "の処理に失敗しました。"
			end try
		end repeat
		
	end tell
end open