• 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
Re: Replace names of files in different folders
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Replace names of files in different folders


  • Subject: Re: Replace names of files in different folders
  • From: Jan Bultereys <email@hidden>
  • Date: Wed, 12 Apr 2006 17:36:11 +0200
  • Thread-topic: Replace names of files in different folders

Hi,
I think I found the solution to replace the "variable choose folder"

set BELGIUM_NL to "FileTransfer_BEL:EUROPEAN_PAGES:BELGIUM_NL:" as alias
set BELGIUM_FR to "FileTransfer_BEL:EUROPEAN_PAGES:BELGIUM_FR:" as alias

set jobs_list to ¬
    {{folder_name:BELGIUM_NL, name_changes:{{"OG1H", "GF1F"}, {"OG2H",
"GF2F"}}}, ¬
        {folder_name:BELGIUM_FR, name_changes:{{"OG1H", "GW1W"}, {"OG2H",
"GW2W"}}}}

repeat with job_ref in jobs_list
    set source_folder to folder_name of job_ref
    rename_items_in_folder(source_folder, name_changes of job_ref)
end repeat

...... (then rest of script)

Is this correct has? It seems to work.

Many thanks for your great feedback
jan







> From: Jan Bultereys <email@hidden>
> Date: Wed, 12 Apr 2006 16:16:02 +0200
> To: has <email@hidden>, "email@hidden"
> <email@hidden>
> Conversation: Replace names of files in different folders
> Subject: Re: Replace names of files in different folders
>
> Thanks has,
>
> How do I select the "fixed" folder?
> I don't want a "choose folder" dialog...
>
> This should be the "source folders":
> set the BELGIUM_FR to "FileTransfer_BEL:EUROPEAN_PAGES:BELGIUM_FR:" as alias
> set the BELGIUM_NL to "FileTransfer_BEL:EUROPEAN_PAGES:BELGIUM_NL:" as alias
>
> Already many thanks for your input
> jan
>
>
>> From: has <email@hidden>
>> Date: Wed, 12 Apr 2006 14:01:37 +0100
>> To: "email@hidden" <email@hidden>
>> Subject: Re: Replace names of files in different folders
>>
>>  Jan Bultereys wrote:
>>
>>> Hi does anyone have a better solution:
>>
>> Not tested but should work:
>>
>>
>> set jobs_list to {¬
>>    {folder_name:"BELGIUM_NL", name_changes:{{"OG1H", "GW1W"}, {"OG2H",
>> "GW2W"}}}, ¬
>>    {folder_name:"BELGIUM_FR", name_changes:{{"OG1H", "GF1F"}, {"OG2H",
>> "GF2F"}}} ¬
>>       }
>>
>> repeat with job_ref in jobs_list
>>    set source_folder to choose folder with prompt folder_name of job_ref
>>    rename_items_in_folder(source_folder, name_changes of job_ref)
>> end repeat
>>
>> to rename_items_in_folder(the_folder, changes_list)
>>    tell application "Finder"
>>       --rename items in this folder
>>       repeat with item_ref in (get items of the_folder)
>>          set item_name to name of item_ref
>>          repeat with change_ref in changes_list
>>             set {search_string, replace_string} to change_ref
>>             if item_name contains search_string then
>>                set name of item_ref to ¬
>>                   my find_and_replace(item_name, search_string,
>> replace_string)
>>                exit repeat
>>             end if
>>          end repeat
>>       end repeat
>>       --recursively rename items in any sub-folders
>>       repeat with sub_folder_ref in (get folders of the_folder)
>>          my rename_items_in_folder(sub_folder_ref, search_string,
>> replace_string)
>>       end repeat
>>    end tell
>> end rename_items_in_folder
>>
>> to find_and_replace(the_string, search_string, replace_string)
>>    set AppleScript's text item delimiters to search_string
>>    set temp_list to every text item of the_string
>>    set AppleScript's text item delimiters to replace_string
>>    set the_string to the temp_list as string
>>    set AppleScript's text item delimiters to ""
>>    return the_string
>> end find_and_replace
>>
>>
>> HTH
>>
>> has
>>
>> --
>> http://freespace.virgin.net/hamish.sanderson/
>>  _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Applescript-users mailing list      (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>>
c
>> edepot.com
>>
>> 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

  • Follow-Ups:
    • Re: Replace names of files in different folders
      • From: has <email@hidden>
References: 
 >Re: Replace names of files in different folders (From: Jan Bultereys <email@hidden>)

  • Prev by Date: Text Item Delimiter Problem
  • Next by Date: Re: Text Item Delimiter Problem
  • Previous by thread: Re: Replace names of files in different folders
  • Next by thread: Re: Replace names of files in different folders
  • Index(es):
    • Date
    • Thread