Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Change the date sort order in FolderOrg X Apps

Doug Everly has updated his incredibly useful FolderOrg X folder action script (previously discussed in this hint) for compatibility with Safari 1.2, but I prefer to keep my folder organized by the international yyyy-mm-dd format instead of the default January 1 2003 format. Since the script is fully editable, open it with your favorite AppleScript editor and change this (shown as three lines here; not necessarily that way in the code):


  -- format date for folder's name (in January 1 2003 format)
  copy word 2 of ((current date) as text) & " " & word 3 of ¬
  ((current date) as text) & " " & word 4 of ((current date) ¬
  as text) to the_date
to this:

   -- format date for folder's name (in yyyy-mm-dd format)
   copy ((offset of (the month of (current date)) in ¬
    "jan feb mar apr may jun jul aug sep oct nov dec ") + 3) / 4 ¬
    as integer to mo
   if mo < 10 then copy "0" & mo as text to mo
   copy day of (current date) to da
   if (day of (current date) < 10) then copy "0" & da as text to da
   copy (year of (current date) as text) & "-" & mo & "-" & da to the_date
Then save your changes.

Disclaimer: the yyyy-mm-dd code was written by Ben Lawson for the AppleScript This Week: Cool Code page. I just put it to use...

    •    
  • Currently 1.00 / 5
  You rated: 1 / 5 (4 votes cast)
 
[9,363 views]  

Change the date sort order in FolderOrg X | 4 comments | Create New Account
Click here to return to the 'Change the date sort order in FolderOrg X' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Change the date sort order in FolderOrg X
Authored by: zs on Feb 20, '04 02:43:02PM
Or you could use:

set the_date to do shell script "date +%Y-%m-%d"

---
zs

[ Reply to This | # ]

Change the date sort order in FolderOrg X
Authored by: horhey23 on Apr 03, '04 04:52:18PM
I tried both mods to the script and neither worked. In fact, the entire script stopped working. Here's how it looks after compiling:
(*
FolderOrg X 1.1
by Doug Everly
DougEverly@mac.com


Version X 1.1
2/11/2004
• Compatible with Safari 1.2 (v125) download files
• Now works with folders, in addition to individual files
• Allows custom icons to be added to the parent folder

Version X 1.0
9/29/2002
Rewrote (simplified code) for use with OS X 10.2 Jaguar.

Version 1.3 (classic version)
11/10/1999

Description:
Attach this script to a folder. When items are added to the folder, the items will be placed inside of a folder label with the current date.
This is especially useful for organizing your "Downloads" folders.
*)

property copy_checks_indicator : true
property item_check_delay_time : 1
property folder_check_delay_time : 2
property special_label_index : 7
property open_with_stuffit : true
property expand_folder : true
property debug_mode : false


on adding folder items to this_folder after receiving added_items
	
	if (debug_mode is true) then say "Running action"
	
	(*-- format date for folder's name
	copy word 2 of ((current date) as text) & " " & word 3 of ((current date) as text) & " " & word 4 of ((current date) as text) to the_date
	copy (this_folder as text) & the_date to todaysfolder
	*)
	
	-- format date for folder's name (in yyyy-mm-dd format)
	copy ((offset of (the month of (current date)) in ¬
		"jan feb mar apr may jun jul aug sep oct nov dec ") + 3) / 4 ¬
		as integer to mo
	if mo < 10 then copy "0" & mo as text to mo
	copy day of (current date) to da
	if (day of (current date) < 10) then copy "0" & da as text to da
	copy (year of (current date) as text) & "-" & mo & "-" & da to the_date
	
	-- make today's folder if it does not already exist
	tell application "Finder"
		if (folder todaysfolder exists) is not true then
			try
				make new folder at folder this_folder with properties {name:the_date}
				if (debug_mode is true) then say "Making folder"
			on error the_error
				display dialog the_error giving up after 30
			end try
			if current view of container window of folder this_folder is name then
				set the expanded of folder todaysfolder to true
			end if
		else
			if (debug_mode is true) then say "Folder already exists"
		end if
	end tell
	
	-- move added items into today's folder
	repeat with i from 1 to the number of items in added_items
		set the_file to item i of added_items
		tell application "Finder"
			-- Contribution by Olivier Scherler to add Safari 1.2 (v125) compatibility and custom icon
			if ((item the_file exists) and (name of item the_file does not end with ".download") and (name of item the_file is not ("Icon" & return))) then
				try
					if (debug_mode is true) then say "Moving file to folder"
					
					(*
					move item the_file to folder todaysfolder
					set the label index of the_file to the 0
					*)
					make new alias at folder todaysfolder to file the_file
				end try
			end if
		end tell
	end repeat
	
end adding folder items to

</code></pre>


[ Reply to This | # ]
Change the date sort order in FolderOrg X
Authored by: jolinwarren on Jun 01, '04 04:35:28AM
horhey23,

Chances are that there is no problem with the script. What you need to check is where the script is located. You need to make sure that the FolderOrgX script (or an alias pointing to it) is in the following location:

Macintosh HD:Library:Scripts:Folder Action Scripts:
If the script is not located there, it will not be run automatically. Try this and see if that solves your problem.

Cheers,
Jolin

[ Reply to This | # ]
Improved change the date sort order in FolderOrg X
Authored by: jolinwarren on Jun 01, '04 04:20:57AM
Here is a slightly cleaner way of using the international date format. Replace the code mentioned in the hint with:


   set mo to ((month of (current date)) as number) 
   if (mo < 10) then (set mo to "0" & (mo as string))
 
   set da to day of (current date)
   if (da < 10) then (set da to "0" & (da as string))

   set the_date to (year of (current date) as string) & "-" & (mo as string) & "-" & (da as string)

Cheers,
Jolin

[ Reply to This | # ]