Re: Replace names of files in different folders
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 10:13:11 +0200
- Thread-topic: Replace names of files in different folders
Thanks emmanuel, but I want this renaming in a workflow, this would be a
manual selection.
This script below works, but I don't know how to make it work in
2 - 3 different "source" folders, with of course different
replacmentstrings.... Anyone any ideas ??
property searchStrings : {"OG1H", " OG1H"}
property replacementStrings : {"GW1W", " GW2W"}
global search_string
global replacement_string
tell application "Finder"
--set the source_folder to "FileTransfer_BEL:EUROPEAN_PAGES:BELGIUM_FR:"
as alias
set source_folder to choose folder with prompt "BELGIUM_FR"
repeat with x from 1 to (get count of items in searchStrings)
set search_string to (item x of searchStrings)
set replacement_string to (item x of replacementStrings)
my createList(source_folder)
end repeat
end tell
on createList(item_list)
set the the_items to list folder item_list without invisibles
set item_list to item_list as string
repeat with i from 1 to number of items in the the_items
set the_item to item i of the the_items
set the_item to (item_list & the_item) as alias
set this_info to info for the_item
--zelf--
--set the this_info to name of the_item as text
set the item_name to the (name of this_info) as text -- EDITED HERE
if item_name contains search_string then
set changedFile to ((the_item as string) & return)
my replaceString(item_name, the_item, search_string,
replacement_string)
end if
if folder of this_info is true then
my createList(the_item)
end if
end repeat
end createList
on replaceString(current_name, the_item, search_string, replacement_string)
set AppleScript's text item delimiters to search_string
set the text_item_list to every text item of the current_name
set AppleScript's text item delimiters to replacement_string
set the new_item_name to the text_item_list as string
set AppleScript's text item delimiters to ""
my set_item_name(the_item, new_item_name)
end replaceString
on set_item_name(this_item, new_item_name)
tell application "Finder"
set the parent_container_path to (the container of this_item) as
text
-- if not (exists item (the parent_container_path &
new_item_name)) then
-- try
set the name of this_item to new_item_name
-- end try
-- end if
end tell
end set_item_name
> From: Emmanuel <email@hidden>
> Date: Tue, 11 Apr 2006 22:01:47 +0200
> To: "email@hidden" <email@hidden>
> Subject: Re: Replace names of files in different folders
>
> At 7:05 PM +0200 4/11/06, Jan Bultereys wrote:
>> Hi does anyone have a better solution:
>
> You'll say if it's better, here is mine.
>
> Download Smile, launch Smile, toggle to "Enhanced Find" in the
> Preferences, open the "Find" dialog, in Finder select the files to
> rename in the 1st folder, in Smile enter "OG1H" as the "Search
> string", enter "GF1F" as the "Replace string", switch the "Find
> target" menu to "Rename files selected in Finder", then click
> "Rename". Do it again for the 2nd folder (mutatis mutandis.)
>
> Emmanuel
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Applescript-users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> 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