Changing modification date of file in a folder

I’m fairly new to Applescript and I am having a problem trying to get files within folders to change the modification date. I can get just a file to change but not if the file is in a folder. I am also getting file permission errors for the files within folders.

Here’s a copy of my code:

on open (ModifyDate)
repeat with a_file in ModifyDate
if (info for a_file) is folder then
set file_list to list folder a_file
repeat with b_file in file_list
set file_path to (path to desktop as text)
if b_file ends with “Store” then
display dialog b_file
else
tell application “Finder”
– display dialog file_path & b_file
set mod_date to modification date of b_file
display dialog file_path & b_file & " - " & mod_date
end tell
end if
end repeat
else
tell application “Finder”
set modification date of a_file to current date
end tell
end if
end repeat
end open

Any thoughts would be appreciated.

I can’t tell exactly what you want the script to do. Can you elaborate?

– Rob

I want to be able to drop a file or folder of files (most probably eps files) on a script icon (droplet?) and have a script that will change the modification date of the file(s). I have it working for a single or group of files to work when not in a folder. I am having problems when files are in a folder and the folder is dropped on the script icon.

Maybe this will work. If you need to modify the script, you should only need to be concerned with processFile (the last handler in the script).

-- based on code by JJ

on open dropped_items
	repeat with item_ in dropped_items
		my processUnknownItem(item_)
	end repeat
end open

to processUnknownItem(item_)
	if folder of (info for item_) is true then
		my processFolder(item_)
	else
		my processFile(item_)
	end if
end processUnknownItem

to processFolder(folder_)
	tell application "Finder"
		set count_ to count (get items of folder_)
		if count_ > 1 then
			set items_ to (items of folder_) as alias list
		else
			if count_ is 1 then
				set items_ to ((item 1 of folder_) as alias) as list
			else
				if count_ is 0 then
					set items_ to {}
				end if
			end if
		end if
	end tell
	
	repeat with item_ in items_
		my processUnknownItem(item_)
	end repeat
end processFolder

to processFile(file_)
	tell application "Finder"
		set modification date of file_ to current date
	end tell
end processFile

Thanks, it works. It all makes sense to me too. It’s a bit different trying to figure out the syntax. I guess I need to find a good book about ApplScript.