set parentFolder to ""
tell application "Finder"
set selectedItems to selection
if ((count of selectedItems) > 0) then
set selectedItem to (item 1 of selectedItems) as alias
set parentFolder to the parent of selectedItem
end if
end tell
return parentFolder
How can I copy the returned volume name to clipboard after selecting an item contained in the disk image? I would like to eventually automate moving the selected item in the disk image and after moving the file rename it at new location with dmg name/parentFolder name that gets returned. Help with that would be amazing but one step at a time as clipboard is giving me fits.
Thanks experts, learn more here than anywhere else. Amazing shared code and tips. I never post so I had better thank you for all answers I find without needing to post.
Cheers and keep up the generous help and tips. I hope I have done a bit to show I have tried…
set parentFolder to ""
tell application "Finder"
set selectedItems to selection
if ((count of selectedItems) > 0) then
set selectedItem to (item 1 of selectedItems) as alias
set parentFolder to the parent of selectedItem
end if
end tell
set the clipboard to parentFolder as text
Now all i need to get this question answered and 25% done with end goal is help in removing the last character from the clipboard as it is a colon…
So, any help in method to remove the colon that appears at the end after DMG name is copied to clipboard?
Thanks, see I am trying!
set parentFolder to ""
tell application "Finder"
set selectedItems to selection
if ((count of selectedItems) > 0) then
set selectedItem to (item 1 of selectedItems) as alias
set parentFolder to the parent of selectedItem
end if
end tell
set the clipboard to parentFolder as text
–
–Either of the methods added below the script above this line will work but last character removal preferred…
get the clipboard
set the clipboard to (replacement of ":" by "" for the result)
on replacement of oldDelim by newDelim for sourceString
set oldTIDs to text item delimiters of AppleScript
set text item delimiters of AppleScript to oldDelim
set strtoks to text items of sourceString
set text item delimiters of AppleScript to newDelim
set joinedString to strtoks as string
set text item delimiters of AppleScript to oldTIDs
joinedString
end replacement
or
set myText to the clipboard as «class utf8»
set {TID, text item delimiters} to {text item delimiters, ":"}
set myText to text items of myText
set AppleScript's text item delimiters to ""
set the clipboard to myText as text
set text item delimiters to TID
added to the end either will remove the colon but anyway to simply snip last character instead of this no colon possible method?
any help with the move and rename part in post #1 would be awesome since I am trying to solve and not looking for a simple handout by the pro scripters? Eh, feel bad writing that, I get enough just reading the threads here!
set someString to text 1 thru -2 of someString