2014-04-26 3 views
1

Мне нужен скрипт для выбора папки, откройте файлы Photoshop в папке, а затем переименуйте файлы на текущее имя слоя плюс расширение файла. (Каждый из слоев будет называться по-разному, поскольку изображения были созданы с объединением данных. Все, что я до сих пор открываю одно изображение и получая имя слоя, не могу понять повторение и переименование файла:Photoshop переименовать в имя слоя

set inputFolder to choose folder 
tell application "Finder" 
    set filesList to files in inputFolder 
    set myDoc to item 1 of filesList as string 
    tell application "Adobe Photoshop CC" 
     set display dialogs to never 
     open alias myDoc 
    end tell 
end tell 
tell application "Adobe Photoshop CC" 
    set layerName to name of current layer of current document as string 
    -- close current document saving no 
    return layerName as string 
end tell 

ответ

1

как это:

set inputFolder to choose folder 
activate application "Adobe Photoshop CC" 
tell application "Finder" 
    set filesList to document files in inputFolder 
    repeat with tFile in filesList 
     set nExtension to name extension of tFile 
     set layerName to my getLayerName(tFile as string) 
     if layerName is not "" then 
      set newName to (layerName & "." & nExtension) 
      if newName is not name of tFile then -- else the name is already the layer name 
       set i to 1 
       repeat while exists item newName in inputFolder -- if same name in the folder (maybe same layer name) 
        set newName to (layerName & i & "." & nExtension) 
        set i to i + 1 
       end repeat 
       set name of tFile to newName 
      end if 
     end if 
    end repeat 
end tell 

on getLayerName(myDoc) 
    tell application "Adobe Photoshop CC" 
     set display dialogs to never 
     open alias myDoc 
     repeat 5 times 
      tell current document to if exists then 
       set layerName to (name of current layer) as string 
       close saving no 
       return layerName 
      end if 
      delay 1 
     end repeat 
    end tell 
    return "" -- no document 
end getLayerName 
0

Brilliant, который работает удовольствие, просто пытаясь назад инженер сценарий, в функции фотошоп на повтор 5 раз будет тот предел, сценарий для работы только с 5 файлов ? и переменная tFile состоит в том, что константа как переменная, кажется, не объявлена? Еще новенький в этом, так простите мой недостаток знаний и благодарности

Смежные вопросы