2017-02-02 37 views
0

我在lightroom中有數千張照片,我將其轉換爲JPEG以節省空間。問題是這些RAW文件已經被分類到不同的發現者標籤標籤中,所以當我導出到JPEG時,這些標籤將被刪除。有沒有辦法保留這些標籤或只是創建一個自動掃描工作流程來掃描目錄並找到具有.CR2/.NEF擴展名的確切文件名的JPEG,並將標籤應用到新的JPEG文件?Automator工作流程查找器標籤

MACOS塞拉利昂

的Mac Pro(晚2013)

3.7 GHz四核Intel Xeon E5

版本10.12.3(16D32)

回答

0

堆棧溢出不是一個地方,你要求某人爲你開發一些東西。你應該開始你的程序,然後你可以從這裏獲得幫助。所以這裏有一些幫助:

1)沒有標準的Automator動作來獲取或設置標籤。但是Applescript包含有關標籤的功能。

2)但是,請注意,即使您可以在Finder中設置多個,AppleScript功能今天也僅限於每個文件的單個顏色標籤。因此,如果您已經爲每個CR2或NEF文件設置了多個顏色標籤,Applescript仍然無法爲您提供幫助

3)您需要通過JPEG文件構建「重複」循環,併爲每個循環提取名稱,而不用擴展名。這可以通過:

tell application "Finder" 
    set N to name of aFile 
    set Ext to name extension of aFile 
    set BaseName to text 1 thru ((length of N) - (length of Ext) - 1) of N 
end tell 

4),你必須使用該名稱添加2個可能的擴展名(CR2,NEF),如果該文件中的原始文件夾中存在搜索。你可以通過使用搜索功能「存在」

5)如果CR2/NEF文件存在獲取標籤和使用文件屬性「標籤指數」將其設爲您的JPEG文件:

set myLabel to label index of file CR2 -- to read CR2 file label 
set label index of aFile to myLabel -- to assign the label found to your new jpg file 

6)因爲您的Jpg文件與原始文件位於相同的文件夾/子文件夾中,您只需選擇一個包含所有文件的文件夾即可。對於每個jpg,在相同的文件夾級別搜索原始文件是否存在。包含文件的文件夾由「容器」調用。從所有子文件夾級別獲取文件使用「全部內容」。我只是添加一個過濾器,只獲得擴展名爲「JPG」或「JPG」的文件。您可能必須將該列表擴展到您的擴展。

總之它給:

-- possible values label index: 0= no label, 1=orange, 2=Red, 3=yellow, 4=blue, 5=pink, 6=green, 7=grey 
set myFolder to choose folder with prompt "Select folder containing JPEG and raw files" 

tell application "Finder" 
set JPEGFiles to every file in entire contents of folder myFolder whose name extension is in {"JPG", "jpg"} 
repeat with aFile in JPEGFiles -- loop through all jpeg files 
    -- extract name of Jpg file without extension 
    set N to name of aFile 
    set Ext to name extension of aFile 
    set parentFolder to (container of aFile) as string -- get folder 
    set BaseName to text 1 thru ((length of N) - (length of Ext) - 1) of N 
    -- build possible raw file names with extension .CR2 or .NEF 
    set CR2 to (parentFolder & BaseName & ".CR2") as string 
    set NEF to (parentFolder & BaseName & ".NEF") as string 

    -- search existing label and assign it to jpg file 
    set myLabel to 0 -- default no label 
    if CR2 exists then set myLabel to label index of file CR2 -- get label of .CR2 if exists 
    if NEF exists then set myLabel to label index of file NEF -- get label of .NEF if exists 
    if myLabel > 0 then set label index of aFile to myLabel -- if label found, assignment to jpg file 
end repeat -- loop to next file in jpg folder 
end tell 
+0

謝謝!你能把它放在一起嗎?我不確定這兩段代碼在第一個答案中加入了 –

+0

腳本。 – pbell

+0

太棒了!完美的作品。現在我需要它也包括所有的子文件夾。可能? –