Re: simplify this script
Re: simplify this script
- Subject: Re: simplify this script
- From: Luca Pozzato <email@hidden>
- Date: Tue, 14 Dec 2004 18:41:50 +0100
hi Jan,
you may adopt or adapt this script (made on System 9)
---------
property mainPath : path to startup disk
property SourceFolder : (mainPath & "desktop folder:FINAL_RESULT:") as text
property DestinationFolder : (mainPath & "desktop
folder:FINAL_RESULT_PAGES:") as text
tell application "Finder"
repeat with i from 1 to 500
set mystart to ("PAG" & i & "_") as text
set mylist to {}
set mylist to (every item of folder SourceFolder whose name starts
with mystart)
if mylist {} then
repeat with myfile in every item of mylist
set currentDestination to ((DestinationFolder & i & ":") as
text)
if not (exists folder currentDestination) then
make new folder at folder DestinationFolder with
properties {name:i}
end if
try
move (myfile as alias) to folder currentDestination with
replacing
on error myMSG
beep
display dialog myMSG giving up after 3
end try
end repeat
end if
end repeat
end tell
---------
Luca
> From: "Jan-Bultereys" <email@hidden>
> Date: Tue, 14 Dec 2004 15:27:46 +0100
> To: <email@hidden>
> Subject: simplify this script
>
> Hi,
>
> Can someone help me to simplify this script.....
> Look at block 2 .... it's just the same as block 1 but it is pointing to a
> folder called "2" instead of "1"
>
> I will have to do this 500 times and I guess this is not the best solution to
> copy and pasted
> the blocks over and over....?
>
> just a little explanation wath this script does....
> - look at files in "final_result"...
> - if the name starts with "PAG1_" move to folder 1 and then delete "PAG1_" of
> that file name....
> - if the name starts with "PAG2_" move to folder 2 and then delete "PAG2_" of
> that file name....
> .......this has to be done to 500 folders......
>
> any input is very much appreciated,
>
>
> ----begin --- BLOCK PAGE 1 -----
> tell application "Finder"
> activate
> set FINAL_RESULT to folder "to_path_name:FINAL_RESULT:" as alias
> set FINAL_RESULT1 to folder "to_path_name:FINAL_RESULT_PAGES:1" as alias
> set file_list_family to (every item of FINAL_RESULT)
> repeat with temp_file in file_list_family
> set temp_name to name of temp_file
> if temp_name starts with "PAG1_" then
> try
> move temp_file to folder FINAL_RESULT1 with replacing
> end try
> end if
> end repeat
> end tell
> ---declareren van delimiter---
> set text item delimiters to "PAG1_"
> tell application "Finder"
> set FINALRESULT1 to folder "to_path_name:FINAL_RESULT_PAGES:1" as alias
> repeat with i in (get files of folder FINALRESULT1)
> set i's name to text item -1 of (get i's name)
> end repeat
> end tell
> ----END --- BLOCK PAGE 1 -----
>
> ----begin --- BLOCK PAGE 2 -----
> tell application "Finder"
> activate
> set FINAL_RESULT to folder "to_path_name:FINAL_RESULT:" as alias
> set FINAL_RESULT2 to folder "to_path_name:FINAL_RESULT_PAGES:2" as alias
> set file_list_family to (every item of FINAL_RESULT)
> repeat with temp_file in file_list_family
> set temp_name to name of temp_file
> if temp_name starts with "PAG2_" then
> try
> move temp_file to folder FINAL_RESULT2 with replacing
> end try
> end if
> end repeat
> end tell
> ---declareren van delimiter---
> set text item delimiters to "PAG2_"
> tell application "Finder"
> set FINALRESULT2 to folder "to_path_name:FINAL_RESULT_PAGES:2" as alias
> repeat with i in (get files of folder FINALRESULT2)
> set i's name to text item -1 of (get i's name)
> end repeat
> end tell
> ----END --- BLOCK PAGE 2 -----
> set text item delimiters to ""
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Applescript-users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> a.it
>
> This email sent to email@hidden
>
_______________________________________________
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