New Capture Folder
Hello scripting wizards,
I am hoping to create a script that creates a single new Capture Folder within the the current Session "Capture" folder hierarchy.
I would like it to have a UI which prompts for "New Folder Name" and then sets this new folder to be "Set as the Capture Folder" and "Added to Favourites".
Would be Awesome if it also set the naming designation to "Destination Folder Name_Name_3 Digit Counter"
Short and sweet.... but I cant do it!
Any tips would be appreciated. Searched the forums and archive without luck.
Thanks in advance for any helpers.
Matt
I am hoping to create a script that creates a single new Capture Folder within the the current Session "Capture" folder hierarchy.
I would like it to have a UI which prompts for "New Folder Name" and then sets this new folder to be "Set as the Capture Folder" and "Added to Favourites".
Would be Awesome if it also set the naming designation to "Destination Folder Name_Name_3 Digit Counter"
Short and sweet.... but I cant do it!
Any tips would be appreciated. Searched the forums and archive without luck.
Thanks in advance for any helpers.
Matt
0
-
Working on this script... seems to work but not all the time. Occasionally gets unstuck at this add to Favourites section.
set captureCollection to make collection with properties {kind:favorite, file:dirPath}
Just trying to make it Robust so feel free to shoot holes through it.
Cheersset newDirs to getDirs(true)
set fullPaths to makeDirs(newDirs)
addFavorites(fullPaths, true)
on getDirs(askOnce)
-- present a modal asking for a name
set newDirs to []
set previousAnswer to "nil"
try
repeat while previousAnswer is not ""
set theResponse to display dialog ¬
"New Folder Name" default answer ¬
"" buttons {"Cancel", "Next"} ¬
default button ¬
"Next" cancel button "Cancel"
set responseText to text returned of theResponse
if responseText is not "" then
set newDirs to newDirs & responseText
end if
if askOnce then
set previousAnswer to ""
else
set previousAnswer to responseText
end if
end repeat
end try
return newDirs
end getDirs
on makeDirs(dirNames)
tell front document of application "Capture One 11"
set currentCaptureDir to captures
tell application "Finder" to set captureName to name of folder currentCaptureDir
set newDirs to []
-- if the name is not Capture, we need to create our folder under the main Capture dir
if captureName is not "Capture" then
tell application "Finder"
set d to currentCaptureDir as alias
set currentCaptureDir to container of d as alias
end tell
end if
repeat with newName in dirNames
set newDir to POSIX path of currentCaptureDir & newName
set newDirs to newDirs & newDir
tell application "Finder"
try
log "Making new dir " & newDir
make new folder at currentCaptureDir with properties {name:newName}
end try
end tell
log newDir
end repeat
end tell
return newDirs
end makeDirs
on addFavorites(dirPaths, setCapture)
tell front document of application "Capture One 11"
set capture counter to 1
-- Add all paths to favorites
repeat with dirPath in dirPaths
set captureCollection to make collection with properties {kind:favorite, file:dirPath}
end repeat
if setCapture is true and (count of dirPaths) is greater than 0 then
-- Set the first item as the capture folder
set captures to first item in dirPaths
end if
end tell
end addFavorites0 -
In getDirs you might consider trailing leading and trailing blanks or whitespace from responseText, and then checking for a length of zero.
In makeDirs, if the name of the folder is not Capture, you go up one level. What if the the name of that folder isn't Capture?
It is possible that in makeDirs a folder was not created because it already exists, and that it's already mapped to a collection from a previous run of the script. Then in addFavorites, the line
set captureCollection to make collection with properties {kind:favorite, file:dirPath}
is likely to cause an error.0 -
Morning Eric!
Cool. Thanks so much. I will have a bash at it!
Cheers
Matt0 -
Hi Martin
Here is a useful function to remove leading and trailing blanks
on removeLeadingTrailingSpaces(theString)
## 40% faster than a version which trims the string 1 space at a time
## handles both string and list input correctly
## handles just about any input without crashing
local newString, theSubString, thecount, hasTriggered, indexLow, indexHigh, errMess1
if (list = (get (class of theString))) then
set newString to {}
repeat with theSubString in theString
set the end of newString to removeLeadingTrailingSpaces(theSubString)
end repeat
return newString
else if (text = (get (class of theString))) then
set thecount to (get count of theString)
set hasTriggered to false
repeat with indexLow from 1 to thecount
if " " ≠(get text indexLow of theString as text) then
set hasTriggered to true
exit repeat
end if
end repeat
if not hasTriggered then return ""
repeat with indexHigh from -1 to (-thecount) by -1
if " " ≠(get text indexHigh of theString as text) then exit repeat
end repeat
return (text indexLow thru indexHigh of theString)
else
try
return (get theString as text)
on error errMess1
try
return (get name of theString)
on error
return errMess1
end try
end try
end if
end removeLeadingTrailingSpaces0 -
Whoa! Nice
Thanks again!0 -
Hi Matthew, I see you're using my capture folder script from GitHub, if you've made any improvements I'd be happy to accept a pull request to merge them in.
I know this is fairly old thread, but if you're having any issues with the script I'd be happy to take a look at them.[quote="Matthew Jensen1" wrote:
Working on this script... seems to work but not all the time. Occasionally gets unstuck at this add to Favourites section.
set captureCollection to make collection with properties {kind:favorite, file:dirPath}
Just trying to make it Robust so feel free to shoot holes through it.
Cheersset newDirs to getDirs(true)
set fullPaths to makeDirs(newDirs)
addFavorites(fullPaths, true)
on getDirs(askOnce)
-- present a modal asking for a name
set newDirs to []
set previousAnswer to "nil"
try
repeat while previousAnswer is not ""
set theResponse to display dialog ¬
"New Folder Name" default answer ¬
"" buttons {"Cancel", "Next"} ¬
default button ¬
"Next" cancel button "Cancel"
set responseText to text returned of theResponse
if responseText is not "" then
set newDirs to newDirs & responseText
end if
if askOnce then
set previousAnswer to ""
else
set previousAnswer to responseText
end if
end repeat
end try
return newDirs
end getDirs
on makeDirs(dirNames)
tell front document of application "Capture One 11"
set currentCaptureDir to captures
tell application "Finder" to set captureName to name of folder currentCaptureDir
set newDirs to []
-- if the name is not Capture, we need to create our folder under the main Capture dir
if captureName is not "Capture" then
tell application "Finder"
set d to currentCaptureDir as alias
set currentCaptureDir to container of d as alias
end tell
end if
repeat with newName in dirNames
set newDir to POSIX path of currentCaptureDir & newName
set newDirs to newDirs & newDir
tell application "Finder"
try
log "Making new dir " & newDir
make new folder at currentCaptureDir with properties {name:newName}
end try
end tell
log newDir
end repeat
end tell
return newDirs
end makeDirs
on addFavorites(dirPaths, setCapture)
tell front document of application "Capture One 11"
set capture counter to 1
-- Add all paths to favorites
repeat with dirPath in dirPaths
set captureCollection to make collection with properties {kind:favorite, file:dirPath}
end repeat
if setCapture is true and (count of dirPaths) is greater than 0 then
-- Set the first item as the capture folder
set captures to first item in dirPaths
end if
end tell
end addFavorites0 -
Hi Emory!
Your script is brilliant! Took me a long time to find something suitable.
Basically you have allowed me to convince the studio I am working at to move from LR 🤭 to Capture and I am in heaven. Just had to mimic a few LR steps really.
Anyway it pretty much does everything I need. The only time I have an issue is when there is another Session window open. Easy enough to avoid though.
I didn't have time to incorporate Erics suggestion of "In makeDirs, if the name of the folder is not Capture, you go up one level. What if the the name of that folder isn't Capture?"
I tried to build this script out myself and had issues, then I am came across your master piece!
Cheers!
Pretty sure this will help out a bunch of other C1 guys too.
Thanks again
Matt0 -
Awesome! I'm so glad to hear it's been so helpful.
Contributing to helping convince a studio to move away from LR is a real notch in my belt.
It should be selecting whatever the front-most session is. I can do some testing to make sure it's doing that correctly. I need to test in Capture One 20, anyway.
As far as I know there's no way to get the "original" Capture folder. That could be set as a top-level variable so it would be easier to change if needed.0 -
Emory you have no idea.
I have been trying for 3 years to break these guys.
Once I got the all clear to try C1 (massive task) then I had to make it work closely to our current LR workflow. You made it happen.
3 years of LR nearly killed me.
So now I have half the clients on C1 and half on LR still. Speaking of which do you know of any Metadata Plugins which work for Capture as the Transporter Plugin works for LR?
Hopefully one day I can buy yo a beer!0 -
I'm not familiar with that plugin (or really anything Lightroom, I move from Aperture to C1). Capture One's plugin system is fairly rudimentary compared to Lightroom, but it may be possible to build a plugin depending what you need to do. What are you trying to do with the metadata? 0 -
Lucky you. LR is best avoided!
So basically just trying to map a whole bunch of metadata fields based off the file name really.
I am told some of the meta fields differ in C1 as opposed to LR.
I admit it's pretty much over my head really.
But this is the CSV we would run through Transporter to spit out this image with Meta Data applied which is then trackable through the Client and Studio system.
https://drive.google.com/file/d/1-Yllbxx4G5GLAvWKEoueP2Dh102jhW3S/view?usp=sharing
https://drive.google.com/file/d/1RLpF_6_9fPhx7yxGbxRfPwgpNyb6BohX/view?usp=sharing
My thought process was to just shoot in Capture and then apply Metadata in Bridge after the fact!
Anyway if that makes any sense amazing. I am advised that it cant be done, but just not sure how objective that opinion is.
If you thinks its possible, then I am happy to spend another year or two fighting for it!
Thats all from me
Really appreciate your work. Literally every day. Same with the other photographers working here!
Cheers
Matt0 -
Dealing with everyone's custom DAM is, at this point, largely my job. Nothing can't be done, it just might take a few extra steps. Capture One will handle any properly formatted metadata, although setting that metadata within Capture One isn't always easy (or possible).
We're wandering a bit off the original topic, but I'd love to continue the metadata conversation offline (on a different line?). If you'd like why don't we continue via email, edunn@emorydunn.com.0 -
Hey Jensen,
Is that csv created before processing files or after import to matrix?
Using existing metadata fields to map to other fields isn’t ideal but given how hard it is to deploy a custom panel in bridge I understand why it happens.
It would be relatively straight forward to build a transporter type tool that adds metadata from a csv to processed files as they process there are some bridge scripts that can do this as well. ‘DIY metadata panel’ I think is one. But it’s an extra step that someone needs to ‘not’ forget to do.0 -
Oh and capture studio can do most of this out of the box. 0 -
Capture One Studio, while nice in theory (I really can't wait for/ wish I could use the eventual new scripting capabilities it will provide), is a tough enough sell for large studios and completely out of reach for individuals.
The tooling around using custom EXIF namespaces is pretty poor, even Adobe's products don't reliably handle them. I've been working on tools to help with batch metadata for ages now, one of them I might actually release soon. Of course all of them will always fall into "not forgetting".0 -
The script does an excellent job of creating the capture folder.
But it should be nice to have the new created capture folder selected in Capture One, in that way you can start shooting after running the script and see the shots coming in CO.
Maybe someone knows a solution for that.
Regards, Johan0 -
Change the last if statement to this.
if setCapture is true and (count of dirPaths) is greater than 0 then
-- Set the first item as the capture folder
set captures to first item in dirPaths
browse to path dirPaths
end if
0 -
[quote="EdgeCompany" wrote:
The script does an excellent job of creating the capture folder.
But it should be nice to have the new created capture folder selected in Capture One, in that way you can start shooting after running the script and see the shots coming in CO.
Maybe someone knows a solution for that.
Regards, Johan
If Capture One is set to select new captures the collection will be shown and the newest image selected.
rapdigital’s solution would also work if you don’t want to have Capture One set to select new captures.0
Post is closed for comments.
Comments
18 comments