New Capture Folder

Discussion regarding all scripting related questions
Please DO NOT post to this thread anything that is not directly related to scripting of Capture One.

New Capture Folder

Postby Matthew Jensen1 » Mon Oct 21, 2019 5:13 am

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
Matthew Jensen1
 
Posts: 10
Joined: Sun Jul 05, 2009 1:32 pm

Re: New Capture Folder

Postby Matthew Jensen1 » Mon Oct 21, 2019 11:33 pm

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.

Cheers


Code: Select all
set 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 addFavorites
Matthew Jensen1
 
Posts: 10
Joined: Sun Jul 05, 2009 1:32 pm

Re: New Capture Folder

Postby Eric Nepean » Tue Oct 22, 2019 7:58 am

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.
Eric Nepean
 
Posts: 662
Joined: Sat Oct 25, 2014 8:02 am
Location: Ottawa

Re: New Capture Folder

Postby Matthew Jensen1 » Tue Oct 22, 2019 10:50 pm

Morning Eric!

Cool. Thanks so much. I will have a bash at it!

Cheers

Matt
Matthew Jensen1
 
Posts: 10
Joined: Sun Jul 05, 2009 1:32 pm

Re: New Capture Folder

Postby Eric Nepean » Wed Oct 23, 2019 12:29 am

Hi Martin
Here is a useful function to remove leading and trailing blanks

Code: Select all
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 removeLeadingTrailingSpaces
Last edited by Eric Nepean on Fri Oct 25, 2019 3:03 am, edited 1 time in total.
Eric Nepean
 
Posts: 662
Joined: Sat Oct 25, 2014 8:02 am
Location: Ottawa

Re: New Capture Folder

Postby Matthew Jensen1 » Thu Oct 24, 2019 10:55 pm

Whoa! Nice

Thanks again!
Matthew Jensen1
 
Posts: 10
Joined: Sun Jul 05, 2009 1:32 pm

Re: New Capture Folder

Postby emorydunn » Thu Oct 31, 2019 8:55 pm

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.

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.

Cheers


Code: Select all
set 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 addFavorites
User avatar
emorydunn
 
Posts: 31
Joined: Fri Jun 14, 2013 7:36 am
Location: San Francisco, California

Re: New Capture Folder

Postby Matthew Jensen1 » Fri Nov 01, 2019 1:27 am

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 :oops: 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

Matt
Matthew Jensen1
 
Posts: 10
Joined: Sun Jul 05, 2009 1:32 pm

Re: New Capture Folder

Postby emorydunn » Fri Nov 01, 2019 1:40 am

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.
User avatar
emorydunn
 
Posts: 31
Joined: Fri Jun 14, 2013 7:36 am
Location: San Francisco, California

Re: New Capture Folder

Postby Matthew Jensen1 » Fri Nov 01, 2019 2:03 am

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!
Matthew Jensen1
 
Posts: 10
Joined: Sun Jul 05, 2009 1:32 pm

Re: New Capture Folder

Postby emorydunn » Fri Nov 01, 2019 2:46 am

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?
User avatar
emorydunn
 
Posts: 31
Joined: Fri Jun 14, 2013 7:36 am
Location: San Francisco, California

Re: New Capture Folder

Postby Matthew Jensen1 » Fri Nov 01, 2019 3:37 am

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

Matt
Matthew Jensen1
 
Posts: 10
Joined: Sun Jul 05, 2009 1:32 pm

Re: New Capture Folder

Postby emorydunn » Fri Nov 01, 2019 5:39 am

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.
User avatar
emorydunn
 
Posts: 31
Joined: Fri Jun 14, 2013 7:36 am
Location: San Francisco, California

Re: New Capture Folder

Postby rapdigital » Mon Nov 04, 2019 3:55 am

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.
rapdigital
Certified Professional
Certified Professional
 
Posts: 187
Joined: Mon Feb 02, 2009 1:52 pm

Re: New Capture Folder

Postby rapdigital » Mon Nov 04, 2019 5:09 am

Oh and capture studio can do most of this out of the box.
rapdigital
Certified Professional
Certified Professional
 
Posts: 187
Joined: Mon Feb 02, 2009 1:52 pm

Next

Return to Scripting



Who is online

Users browsing this forum: No registered users and 1 guest