• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
slow folder action script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

slow folder action script


  • Subject: slow folder action script
  • From: Yvan KOENIG <email@hidden>
  • Date: Sun, 8 May 2005 09:12:57 +0200

Hello

I tried to help someone with this folder actions script:


--[Script ranger dans sous-dossiers] property monDossier : "Mes dossiers" property debutNom : "mes MP3s #" property limite : 100

on adding folder items to this_folder after receiving added_items

 tell application "Finder"

 set dossier to ("" & this_folder & monDossier) as alias

set lesDossiers to (every folder in dossier)
if lesDossiers is {} then set lesDossiers to {my cree1dossier(dossier, debutNom & "001")}


set leDernier to (lesDossiers's item 1) as text
repeat with d in lesDossiers
set n_d to d as text
if n_d > leDernier then set leDernier to n_d
end repeat
set cai to count of added_items
set vieuxCompte to (count of (every item in folder leDernier))
if vieuxCompte + cai is not greater than limite then
(* no need to create a new folder *)
repeat with f in added_items
move f as alias to folder leDernier
end repeat
else
set knt1 to limite - vieuxCompte
if vieuxCompte is not limite then
(* fills the existing subfolder *)
repeat with i from 1 to knt1
move (added_items's item i) as alias to folder leDernier
end repeat -- with i …
end if -- vieuxCompte is not limite
repeat
(* create a new folder *)
set oldnum to (text -4 thru -2 of leDernier) as number
set newNum to oldnum + 1
set leDernier to (my cree1dossier(dossier, debutNom & text -3 thru -1 of ("000" & newNum))) as text
set reste to cai - knt1
if reste > limite then
(* fills the new folder *)
repeat with i from 1 to limite
move (added_items's item (i + knt1)) as alias to folder leDernier
end repeat -- with i …
set knt1 to knt1 + limite
else
(* move the remaining files *)
repeat with i from 1 to reste
move (added_items's item (i + knt1)) as alias to folder leDernier
end repeat -- with i …
exit repeat
end if -- reste > limite
end repeat
end if -- vieuxCompte + cai is not greater than limite
end tell -- to Finder
end adding folder items to


on cree1dossier(c, n)
 tell application "Finder"
 set d to make new folder at c with properties {name:n}
 end tell
 return d
 end cree1dossier

--[/Script]


Dropped files are moved in subfolders whose contents is limited to 100 files.
Alas, the user drops hundreds of files at a time and the script appears to be slow.


Is one of you able to fasten it or is it no other soluce than saying : drop smaller sets of files?

Yvan KOENIG
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: slow folder action script
      • From: kai <email@hidden>
  • Prev by Date: Re: When are we going to be able to get selected text in a Cocoa Application?
  • Next by Date: Re: [ann] TextCommands 0.1.0
  • Previous by thread: Re: Data events suite
  • Next by thread: Re: slow folder action script
  • Index(es):
    • Date
    • Thread