How to rename folders inside CaptureOne ??
This probably sounds like a dumb question and it probably is, but I can't see how to rename a folder insie C1. I need to do it from inside the programme and not use a shell script in Finder so that C1 keeps track of what the folders are called. The bit that is stumping me at the moment is the very first step - selecting the folder to change, and finding its name!
Help gratefully received!
Help gratefully received!
0
-
In general, you can get a reference to the collection {catalog folder, Album, Smart Album, Group, Project} and its name from this Applescript command:
or
tell application "Capture One 20" to tell current document to set {theCollection, theName} to {current collection, current collection's name}
tell application "Capture One 20"
tell current document
set theCollection to current collection
set theName to current collection's name
set {thePath, thePosixPath} to {null, ""}
try
set thePath to current collection's folder
tell me to set thePosixPath to POSIX path of thePath
end try
end tell
end tell
However I know of no way to change the name of a collection or folder using Applescript and Capture One. Capture One's Rename command is not accessible by Applescript. You can't set the name of a collection.
(Perhaps the Move command may do it)
As work around, I would find the folder with Finder, use Finder to change the name, and then use Capture One's relocate caommand (which is scriptable) to find the renamed folder.0 -
Thanks, Eric - even if the news is bad 😊 This might actually be one of those cases where you think you'll script something but then it turns out to be quicker just to do it manually. Less fun, of course! 0 -
I don't see it as that difficult - Extract the Folder's Path
- Tell Finder to rename the folder (you have the path)
- Tell Capture One to Relocate the Folder (you have the new path)
0 -
[quote="Eric Nepean" wrote:
I don't see it as that difficult- Extract the Folder's Path
- Tell Finder to rename the folder (you have the path)
- Tell Capture One to Relocate the Folder (you have the new path)
We start from different levels of competence 😊0 -
Here is an untested script that should do it.
Be careful. Try it first on a test folder with test images you can afford to lose.
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
set foundAPath to false
tell application "Capture One 20"
tell current document
set theCollection to current collection
set theName to current collection's name
set {thePath, thePosixPath} to {null, ""}
try
set thePath to current collection's folder
tell me to set thePosixPath to POSIX path of thePath
set foundAPath to true
end try
if foundAPath then set imagelist to theCollection's images
end tell
end tell
if not foundAPath then error "The collection "" & theName & "" does not have a folder"
if {"Desktop", "Documents", "Pictures", "Applications", "Downloads", "Music", "Library", "System", "Movies", "Public"} contains theName then error "Danger: Do not attempt to change the name of "" & theName & """
try
set newName to text returned of (display dialog "set the file name" default answer "theName")
get text 8 of newName -- trigger an error if the Newname doesn't have at least 8 characters
on error
return
end try
tell application "Finder"
set theFolderAlias to (POSIX file thePosixPath as alias)
set theFolderAlias's name to newName
set newFolderPath to POSIX path of theFolderAlias
end tell
tell application "Capture One 20" to tell theCollection
repeat with anImage in imagelist
set imageName to anImage's name
set newImagePath to newFolderPath & imageName
relink anImage to path newImagePath
end repeat
end tell0 -
I'll try it - thanks so much 😊 0 -
Here is an improved version. - It shows the current folder name correctly
- does a more accurate job of checking for folders that should not be renamed
- New Name length check is removed (not needed)
- Checks that the a folder with the new name does not already exist in the same location
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
set foundAPath to false
tell application "Capture One 20"
tell current document
set theCollection to current collection
set theName to current collection's name
set {thePath, thePosixPath} to {null, ""}
try
set thePath to current collection's folder
tell me to set thePosixPath to POSIX path of thePath
set foundAPath to true
end try
if foundAPath then
set imagelist to theCollection's images
set thePath_s to thePath as text
end if
end tell
end tell
if not foundAPath then error "The collection "" & theName & "" does not have a folder"
set dangerFolder to false
try
set dangerPath to run script "get path to " & theName & " folder"
if thePath_s = (get dangerPath as text) then set dangerFolder to true
end try
if thePath_s = (get path to home folder as text) then set dangerFolder to true
if dangerFolder then error "Danger: You must not attempt to change the name of the Folder "" & theName & """
set newName to text returned of (display dialog "set the file name" default answer theName)
if (theName = newName) then error "You have not selected a new Folder name"
set folderExists to false
set newPosixPath to joinListToString((items 1 thru -3 of (get splitStringToList(thePosixPath, "/")) & newName), "/") & "/"
try
set targetFolder_a to (get alias POSIX file newPosixPath)
set folderExists to true
end try
if folderExists then error "The folder "" & newName & "" already exists"
tell application "Finder"
set theFolderAlias to (POSIX file thePosixPath as alias)
set theFolderAlias's name to newName
set newFolderPath to POSIX path of theFolderAlias
end tell
tell application "Capture One 20" to tell theCollection
repeat with anImage in imagelist
set imageName to anImage's name
set newImagePath to newFolderPath & imageName
relink anImage to path newImagePath
end repeat
end tell
on splitStringToList(theString, theDelim)
## Public Domain
set theList to {}
set astid to AppleScript's text item delimiters
try
set AppleScript's text item delimiters to theDelim
set theList to text items of theString
on error
set AppleScript's text item delimiters to astid
end try
set AppleScript's text item delimiters to astid
return theList
end splitStringToList
on joinListToString(theList, theDelim)
## Public Domain
set theString to ""
set astid to AppleScript's text item delimiters
try
set AppleScript's text item delimiters to theDelim
set theString to theList as string
end try
set AppleScript's text item delimiters to astid
return theString
end joinListToString0 -
Hmm - maybe User Error but what happened is that the folder got re-named but the images didn't find their new home and had to be re-linked by hand? Did it work OK for you? 0 -
[quote="NN13765" wrote:
Hmm - maybe User Error but what happened is that the folder got re-named but the images didn't find their new home and had to be re-linked by hand? Did it work OK for you?
Hmmm, thats not what I intended. I though that the relinking should do it.
I'll have to set up a special folder first, as I don't want to run this on my working files.
Let me look into it.0
Please sign in to leave a comment.
Comments
9 comments