Hi kshyam,
The folder actions script I posted need to be connected to the folder and not run.
Try making a scriptsomething like this:
property folder_refs : {alias "MyImage:Projects:", alias "MyImage:Projects:AD1352K:"}
property folder_names : {"Projects", "AD1352K"}
--
set c to (count folder_refs)
repeat with i from 1 to c
set this_folder to item i of folder_refs
set this_name to item i of folder_names
set n to name of (info for this_folder)
if n is not this_name then
tell application "Finder" to set name of this_folder to this_name
end if
end repeat
Here you need to add alias references to every folder whose name you want to check along with their original names in the second list. Compile your script so the alias references are saved in the script. To test it, rename some of the folders that you entered in the lists, then run the script. The names should change back to original names.
There are two main ways to make the script automatically check the names. You can either make the script a folder action script with the ‘on adding folder actions to’ handler or you can use an ‘idle’ handler.
To make the script a folder action script, you attach it to the folders in question. In your case you would need two seperate scripts. Attach one script to your “SERV:” folder. This script would monitor the name of the “PROJECTS” folder. The second script would be attached to the “PROJECTS” folder and would monitor the sub folders within this folder. You would need to change the list of references and names accordingly. You attach folder action script to folders using the Scripts Menu from the menu bar. Search your computer for information on “folder actions”.
Idle handlers are made to run at intervals of seconds. To make a script with an idle handler, you save the scripts as stay open applications The following script when run as a stay open application will check the references and their names every two seconds:
property folder_refs : {alias "MyImage:Projects:", alias "MyImage:Projects:AD1352K:"}
property folder_names : {"Projects", "AD1352K"}
global c
--
on run -- do initializing stuff
set c to (count folder_refs)
end run
--
on idle
repeat with i from 1 to c
set this_folder to item i of folder_refs
set this_name to item i of folder_names
set n to name of (info for this_folder)
if n is not this_name then
tell application "Finder" to set name of this_folder to this_name
end if
end repeat
return 2 -- check every 2 seconds
end idle
If you run this script from the Script Editor, nothing will happen. It only works when run as an application. A simple example you can use to test if you’re doing things right is this:
on idle
beep 1
return 2
end idle
When you run this as a stay open application it should beep every two seconds.
Note that their have been many posts about folder actions being inconsistant. You might want to go with the idle handler.
gl,