поэтому у меня есть этот сценарий Apple, который я использовал для вставки имени папки в начало всех файлов в папке. Скрипт может проходить через каждую папку и нацеливаться на все файлы и оказался очень полезным.
set the_folder to (choose folder)
renamefilesinside(the_folder)
on renamefilesinside(next_folder)
tell application "Finder"
set folder_name to name of next_folder & " "
set folder_contents to every item of next_folder
repeat with each_item in folder_contents
if kind of each_item is "folder" then
my renamefilesinside(each_item)
else
set name of each_item to folder_name & " " & name of each_item
end if
end repeat
end tell
end renamefilesinside
Источник: https://discussions.apple.com/thread/275167
Однако теперь я удалил часть имен папок и хотел бы, чтобы к файлам применялся эффект вычитания, поэтому скрипт возьмет файлы, просмотрит имя родительской папки и удалит общие символы.
К сожалению, я очень мало знаю о сценариях Apple, поэтому я надеюсь, что это простая настройка, которую кто-то здесь может сделать.
Спасибо за любую помощь, которую вы можете дать!
Вы можете получить имя файла, затем установить разделитель текстовых элементов на имя содержащей папки, затем поместить текстовые элементы имени файла в список, который будет игнорировать разделитель (имя папки), а затем сбросить разделитель текстовых элементов на "" пусто и приводит имя к строке. Это ОЧЕНЬ распространенный трюк Applescript.
set the_folder to (choose folder)
renamefilesinside(the_folder)
on renamefilesinside(next_folder)
tell application "Finder"
set folder_name to name of next_folder
set folder_contents to every item of next_folder
repeat with each_item in folder_contents
if kind of each_item is "folder" then
my renamefilesinside(each_item)
else
set n to name of each_item
set AppleScript's text item delimiters to folder_name
set n to text items of n
set AppleScript's text item delimiters to ""
set n to n as string
set name of each_item to n
end if
end repeat
end tell
end renamefilesinside
Шонксер
слабые