Skip to main content
mentioned the exact names of the Automator actions to use, added image alt text, fixed grammar
Source Link

OK, new approach here. Caution: I don't have a system upgraded to Lion (my computer came with Lion installed) so I can't test this. Untested code; back up before trying this code!!!.

  1. Create a new Workflow in Automator.

  2. Set the workflow to accept files or folders from the Finder by adding the “Ask for Finder items” action.

  3. Have the workflow run an AppleScript by adding the “Run AppleScript” action.

enter image description herescreenshot of the workflow in Automator

OK, new approach here. Caution: I don't have a system upgraded to Lion (my computer came with Lion installed) so I can't test this. Untested code; back up before trying this code!!!.

  1. Create a new Workflow in Automator.

  2. Set the workflow to accept files or folders from the Finder

  3. Have the workflow run an AppleScript.

enter image description here

OK, new approach here. Caution: I don't have a system upgraded to Lion (my computer came with Lion installed) so I can't test this. Untested code; back up before trying this code!

  1. Create a new Workflow in Automator.

  2. Set the workflow to accept files or folders from the Finder by adding the “Ask for Finder items” action.

  3. Have the workflow run an AppleScript by adding the “Run AppleScript” action.

screenshot of the workflow in Automator

Updates suggested below
Source Link
Daniel
  • 35.1k
  • 31
  • 155
  • 193
on run {input, parameters}
    do shell script ""sudo /usr/sbin/systemsetup -setusingnetworktime Off" with administrator privileges
    tell application "Finder"
        repeat with x in input
            set myfile to POSIX path of x
            set nm to name of x
            set d to modification date of x
            set yr to (character 3 of (year of d as string)) & (character 4 of (year of d as string))
            set mth to (month of d as number) as string
            if length of mth is 1 then set mth to "0" & mth
            set dy to day of d as string
            if length of dy is 1 then set dy to "0" & dy
            set h to hours of d as string
            if length of h is 1 then set h to "0" & h
            set m to minutes of d as string
            if length of m is 1 then set m to "0" & m
            set s to seconds of d as string
            if length of s is 1 then set s to "0" & s
            set dt to mth & ":" & dy & ":" & yr as string
            set tm to h & ":" & m & ":" & s as string
            do shell script ""sudo /usr/sbin/systemsetup -setdate '" & dt & "'" with administrator privileges
            do shell script ""sudo /usr/sbin/systemsetup -settime ''"'" & tm & "'" with administrator privileges
            do shell script "mv \"" & myfile & "\" /var/tmp/clobber"
            do shell script "mv /var/tmp/clobber \"" & myfile & "\""
        end repeat
    end tell
    do shell script ""sudo /usr/sbin/systemsetup -setusingnetworktime On" with administrator privileges
    return input
end run
on run {input, parameters}
    do shell script "/usr/sbin/systemsetup -setusingnetworktime Off"
    tell application "Finder"
        repeat with x in input
            set myfile to POSIX path of x
            set nm to name of x
            set d to modification date of x
            set yr to (character 3 of (year of d as string)) & (character 4 of (year of d as string))
            set mth to (month of d as number) as string
            if length of mth is 1 then set mth to "0" & mth
            set dy to day of d as string
            if length of dy is 1 then set dy to "0" & dy
            set h to hours of d as string
            if length of h is 1 then set h to "0" & h
            set m to minutes of d as string
            if length of m is 1 then set m to "0" & m
            set s to seconds of d as string
            if length of s is 1 then set s to "0" & s
            set dt to mth & ":" & dy & ":" & yr as string
            set tm to h & ":" & m & ":" & s as string
            do shell script "/usr/sbin/systemsetup -setdate '" & dt & "'"
            do shell script "/usr/sbin/systemsetup -settime ''" & tm & "'"
            do shell script "mv \"" & myfile & "\" /var/tmp/clobber"
            do shell script "mv /var/tmp/clobber \"" & myfile & "\""
        end repeat
    end tell
    do shell script "/usr/sbin/systemsetup -setusingnetworktime On"
    return input
end run
on run {input, parameters}
    do shell script "sudo /usr/sbin/systemsetup -setusingnetworktime Off" with administrator privileges
    tell application "Finder"
        repeat with x in input
            set myfile to POSIX path of x
            set nm to name of x
            set d to modification date of x
            set yr to (character 3 of (year of d as string)) & (character 4 of (year of d as string))
            set mth to (month of d as number) as string
            if length of mth is 1 then set mth to "0" & mth
            set dy to day of d as string
            if length of dy is 1 then set dy to "0" & dy
            set h to hours of d as string
            if length of h is 1 then set h to "0" & h
            set m to minutes of d as string
            if length of m is 1 then set m to "0" & m
            set s to seconds of d as string
            if length of s is 1 then set s to "0" & s
            set dt to mth & ":" & dy & ":" & yr as string
            set tm to h & ":" & m & ":" & s as string
            do shell script "sudo /usr/sbin/systemsetup -setdate '" & dt & "'" with administrator privileges
            do shell script "sudo /usr/sbin/systemsetup -settime '" & tm & "'" with administrator privileges
            do shell script "mv \"" & myfile & "\" /var/tmp/clobber"
            do shell script "mv /var/tmp/clobber \"" & myfile & "\""
        end repeat
    end tell
    do shell script "sudo /usr/sbin/systemsetup -setusingnetworktime On" with administrator privileges
    return input
end run
Source Link
Daniel
  • 35.1k
  • 31
  • 155
  • 193

OK, new approach here. Caution: I don't have a system upgraded to Lion (my computer came with Lion installed) so I can't test this. Untested code; back up before trying this code!!!.

My previous answer was based on the sort order used by the Downloads stack in the Dock. The Date Added field in the Finder appears to be based on Spotlight information, which is difficult to hack. It also isn't accessible via AppleScript. But, there does seem to be a workaround.

  1. Create a new Workflow in Automator.

  2. Set the workflow to accept files or folders from the Finder

  3. Have the workflow run an AppleScript.

Use this AppleScript:

on run {input, parameters}
    do shell script "/usr/sbin/systemsetup -setusingnetworktime Off"
    tell application "Finder"
        repeat with x in input
            set myfile to POSIX path of x
            set nm to name of x
            set d to modification date of x
            set yr to (character 3 of (year of d as string)) & (character 4 of (year of d as string))
            set mth to (month of d as number) as string
            if length of mth is 1 then set mth to "0" & mth
            set dy to day of d as string
            if length of dy is 1 then set dy to "0" & dy
            set h to hours of d as string
            if length of h is 1 then set h to "0" & h
            set m to minutes of d as string
            if length of m is 1 then set m to "0" & m
            set s to seconds of d as string
            if length of s is 1 then set s to "0" & s
            set dt to mth & ":" & dy & ":" & yr as string
            set tm to h & ":" & m & ":" & s as string
            do shell script "/usr/sbin/systemsetup -setdate '" & dt & "'"
            do shell script "/usr/sbin/systemsetup -settime ''" & tm & "'"
            do shell script "mv \"" & myfile & "\" /var/tmp/clobber"
            do shell script "mv /var/tmp/clobber \"" & myfile & "\""
        end repeat
    end tell
    do shell script "/usr/sbin/systemsetup -setusingnetworktime On"
    return input
end run

Select the files that do not already have a Date Added (sort by Date Added in Finder, then select the part of the list without a Date Added) and run this service.

enter image description here