Mac "Date modified" script strange behavior in Mavericks

Remcokw

macrumors newbie
Original poster
Jul 31, 2010
3
0
Does anyone know why this Date Modified script is not working anymore in Mavericks?

I know there are some security issues in Mavericks and I have added applescript, finder, terminal and the script itself (Saved as application) in the Accessbility tab in security and privacy.

When dragging a file onto the script application the date modified changes in 14-12-2036 (!)

Whats going wrong here???:confused:


Code:
on open files_
  display dialog "enter the new creation date in format YYYYMMDDhhmm ex: 200112251730:" default answer "" buttons {"Cancel", "Continue"}
  copy the result as list to {the new_creation_date, the button_pressed}
  repeat with file_ in files_
    tell application "Finder"
      set file_ to POSIX path of file_
      do shell script "touch -t " & new_creation_date & " " & quoted form of file_
    end tell
  end repeat
end open
 

kryten2

macrumors 6502a
Mar 17, 2012
996
59
Belgium
What did you set the new_creation_date to or did you leave it blank? I would also move the do shell script statement outside of the tell "Finder" block.
 

mrichmon

macrumors 6502a
Jun 17, 2003
873
2
When dragging a file onto the script application the date modified changes in 14-12-2036 (!)

Whats going wrong here???:confused:
Since the date is provided by the user, one thing to check is what date was typed in by the user.

As a general coding observation, it seems very strange to collect a flag indicating which button was clicked by the user but never checking the value of the flag. (For example, have you tested the "Cancel" behavior? It looks like the file dates will change no matter which button is clicked.)
 

Remcokw

macrumors newbie
Original poster
Jul 31, 2010
3
0
Hi there, thanks for the tips.

This script used to work fine in SL and Lion.

(For example, have you tested the "Cancel" behavior? It looks like the file dates will change no matter which button is clicked.)
I have tried the Cancel button. It does work but indeed gives an error. At least it doesn't change the date modified of the file.

What did you set the new_creation_date to or did you leave it blank? I would also move the do shell script statement outside of the tell "Finder" block.
New date is set to any date. I have tested this many many times with different dates. Last attempts where: 201401012345

Move the script statement outside the finder block.. Can you give an example?

Thanks!
 

kryten2

macrumors 6502a
Mar 17, 2012
996
59
Belgium
Move the script statement outside the finder block.. Can you give an example?

Thanks!
You can remove the tell "Finder" block completely.

Code:
on open files_
	set {new_creation_date, button_pressed} to {text returned, button returned} of (display dialog "enter the new creation date in format YYYYMMDDhhmm ex: 200112251730:" default answer "" buttons {"Cancel", "Continue"})
	if button_pressed is "Continue" then
		repeat with file_ in files_
			set file_ to POSIX path of file_
			do shell script "touch -t " & new_creation_date & " " & quoted form of file_
		end repeat
	end if
end open
 
Last edited:

Remcokw

macrumors newbie
Original poster
Jul 31, 2010
3
0
Marvelous ! It works again ! :)

Haven't tried this one before !

Thanks a lot Kryten2 Dank je wel !! (I am Dutch)

Great help ! :)