#1 : 15/04-21 15:30 John Johnson
Posts: 8
|
Hi David, I currently have to do a 2 time manual pass to rename my photo files using the methods/scripts and process outlined below. This works well, but I have to do 2 x stage manual process. Is there a way to combine/structure these commands/scripts that would allow me to do a 1 time fully automated execution/pass?. Note: The original file name dates and location are known in advance allowing me to construct my CSV file. Original File Names (out of camera) -8503919 -8503920 -8503921 -8503922 etc. Execute the following: Remove Count 8 Starting at 1 Add ExifTool:Createdate Remove Count 8 Starting at 1 Add <Inc Nr:001:1> Prebatch Script lastDate = ""; Script name = item.newBasename; if ((date = name.slice(0,10 )) != lastDate) { lastDate = date; incNo = 0; } return name + " " + ("00" + ++incNo).slice(-3); Remove Count 5 Starting at 5 Executing the above results in 2020_11_02_001.NEF 2020_11_02_002.NEF 2020_11_02_003.NEF 2020_11_02_.NEF 2020_11_06_.NEF 2020_11_06_002.NEF 2020_11_06_003.NEF 2021_01_26_001.NEF 2021_01_26_002.NEF 2021_01_26_003.NEF 2021_01_26_005.NEF 2021_02_01_001.NEF 2021_02_01_002.NEF I then start the batch to update the names in the direcotry and then drag these new files for renaming into the app; I then Execute the following Script Pre Batch replace = {}; csv = "C:\\Users\\John Johnson\\Desktop\\Script Test\\Date Location.csv"; csv = '::\"' +csv + '\"'; j=1; while (line = app.parseTags('<File Line:' + j + csv + '>')) { match = line.match(/(.*),(.*)/); replace[match[1]] = match[2]; j++; } I Run the Script using the CSV File below match = item.name.match(/([^ ]*)(.*)/); place = replace[match[1]]; if (place) return match[1] + " " + place + match[2]; 2020_11_02 Black Bear 001.NEF 2020_11_02 Black Bear 002.NEF 2020_11_02 Black Bear 003.NEF 2020_11_02 Black Bear 004.NEF 2020_11_06 Library Springs 001.NEF 2020_11_06 Library Springs 002.NEF 2020_11_06 Library Springs 003.NEF 2021_01_26 Rolling Meadows 001.NEF 2021_01_26 Rolling Meadows 002.NEF 2021_01_26 Rolling Meadows 003.NEF 2021_01_26 Morton Arboretum 005.NEF 2021_02_01 Morton Arboretum 001.NEF 2021_02_01 Morton Arboretum 002.NEF CSV File 2020_11_02,Black Bear 2020_11_06,Library Springs 2021_01_26,Rolling Meadows 2021_02_01,Morton Arboretum |
#2 : 16/04-21 13:42 David Lee
Posts: 1125
|
This should work...
Pre batch script: places = {}; incNrs = {}; csv = "C:\\Users\\John Johnson\\Desktop\\Script Test\\Date Location.csv"; csv = '::\"' +csv + '\"'; j=1; while (line = app.parseTags('<File Line:' + j + csv + '>')) { match = line.match(/(.*),(.*)/); places[match[1]] = match[2]; incNrs[match[1]] = 0; j++; } Main script: date = app.parseTags('<ExifTool:CreateDate>').slice(0,10); if (place = places[date]) { return date + ' ' + place + ' ' + ('00' + ++incNrs[date]).slice(-3); } |
#3 : 16/04-21 21:52 John Johnson
Posts: 8
|
Reply to #2:
Excellent !!!! Works like a dream"!!! Thanks very much David. |