[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)
				set Fluctuation to 0
			end if
		end timeout
			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
				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