• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Modification date checker
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Modification date checker


  • Subject: Modification date checker
  • From: Alex Husted <email@hidden>
  • Date: Thu, 24 Mar 2005 13:50:46 -0500

I wrote this little script to check which files in a particular set of
folders have been modified in the time since the script was last run. It
works fine, but never on the first try. The first time I run it, it writes
the "error getting date" to the log because my try statement fails. If I run
it immediately again  it works fine, but since I am using the mod date of
the log file as the record of when the script was last run, running it twice
all the time is not an option.
any help would be much appreciated
Alex


global x
set x to false
global error_log
set error_log to "SomeNetworkWindozeDrive:New Project Mod Log.txt"
global modFiles
set modFiles to {}
global modDates
set modDates to {}
global lastCheck

tell application "Finder"
	set theFolder to "SomeOtherNetworkWindozeDrive:New Projects 2005:"
as alias
	set lastCheck to modification date of file error_log
	my checkFiles(theFolder)
	my mod_log(modFiles, modDates)
	if x is true then
		tell application "BBEdit"
			activate
			open error_log
		end tell
	end if
end tell

on checkFiles(theFolder)
	tell application "Finder"
		set theFiles to (every file of theFolder)
		if (length of theFiles) > 0 then
			repeat with i from 1 to (length of theFiles)
				try
					set modDate to modification date of
item i of theFiles as date
					--if (current date) - (modDate) <
(86400) then
					if modDate > lastCheck then
						set x to true
						set end of modFiles to (name
of theFolder & ":" & name of item i of theFiles)
						set end of modDates to
modDate
					end if
				on error
					set end of modFiles to (name of
theFolder & ":" & name of item i of theFiles)
					set end of modDates to "Error
getting date"
				end try
			end repeat
		end if

		set subfolders to every folder of theFolder
		repeat with this_subfolder in subfolders
			my checkFiles(this_subfolder)
		end repeat
	end tell
end checkFiles

on mod_log(modFiles, modDates)
	try
		open for access file error_log with write permission
		write ((return & "Report completed: " & (current date) as
string) & return) to file error_log starting at eof
		if length of modFiles > 0 then
			repeat with j from 1 to length of modFiles
				write ((item j of modFiles) & tab & (item j
of modDates) & return) to file error_log starting at eof
			end repeat
		end if
	end try
	try
		close access file error_log
	end try
end mod_log


This e-mail and any files transmitted with it are intended solely for the
use of the addressee. This e-mail may contain confidential and/or legally
privileged information. Any review, transmission, disclosure, copying, or
any action taken or not taken, by other than the intended recipient, in
reliance on the information, is prohibited. If you received this e-mail in
error, notify the sender and delete this e-mail from your computer and
network. In addition, please be advised that Edmund Optics reserves the
right to monitor, access and review all messages, data and images
transmitted through our e-mail system. By using our e-mail system, you
consent to this monitoring.


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Modification date checker
      • From: Emmanuel <email@hidden>
  • Prev by Date: Re: Calling handlers in other scripts inside AS application
  • Next by Date: RE: Issue with AS variable in OS 10.2
  • Previous by thread: Re: This Used To Work
  • Next by thread: Re: Modification date checker
  • Index(es):
    • Date
    • Thread