Copying part of filename in Finder

Hello Mavens,
this is what I'd like to do:
Enhance the Replace Text in Filename script that Apple provides with the OS in such a way that I can
1 - select a filename, as if for editing, in a folder
2 - select part of a filename (the part I want to change)
*3 - make that selection available to the script*
4 - use it as the default text for "Enter text to replace in filename".
The critical step is #4 (in bold)
"Selection" for the script is the file itself (as alias, I presume) and not a word in the filename even if it is selected.
The script can not utilize "copy selection".
The Finder's Copy menu item is not recordable.
I'm stuck - any suggestions?

The critical step is #4 (in bold)
You mean step 3, right?
The Finder's Copy menu item is not recordable.
Why are you using recording? Recorded scripts are rarely, if ever, optimal.
At the end of the day, what you're asking for is something complex. That's not to say it can't be done, but that it's going to have a lot of gotchas that you haven't yet thought about.
Here's one approach to what I think you're trying to do:
tell application "Finder"
  set curFile to item 1 of (get selection) -- get the selected file
  set curFilename to name of curFile -- find its name
  -- the following code copies (via Cmd-C) the selection
  -- you probably need some error checking here to make sure some text is selected
  -- for example, unexpected things will happen if you copy a file or folder
  tell application "System Events"
    tell process "Finder"
      keystroke "c" using {command down}
    end tell
  end tell
  delay 1
  -- now we have the selected text, so prompt the user
  set selectedText to (get the clipboard as text)
  set myDialog to display dialog "Enter replacement text" default answer selectedText
  set replacementText to text returned of myDialog
  -- probably want some sanity check here to make sure the user didn't go nuts
  -- bad things may happen if the user enters invalid characters
  -- now work out what the new name would be by replacing the selected text with the new text
  set newFilename to my replaceText(curFilename, selectedText, replacementText)
  -- and rename the file
  set name of curFile to newFilename
end tell
on replaceText(cur, old, repl)
  set my text item delimiters to old
  set new to text items of cur
  set my text item delimiters to repl
  new as text
  return new as text
end replaceText

Similar Messages

  • I have a document that in Word required a password to open. I copied and pasted it to Pages. Put the password protection on. Now if I click on that filename in Finder it automatically opens.Why. Anyone can read it. How do I protect it again?

    I have a document that in Word required a password to open. I copied and pasted it to Pages. Put the password protection on. Now if I click on that filename in Finder it automatically opens.Why. Anyone can read it. How do i protect it again?

    You saved it after setting the Password? :
    Inspector > Document > Document > Require Password to Open
    I just tested it and it shows up ijn The Finder with a padlock on the file icon and does require a password to open.
    Peter

  • Can I copy part of a PDF from iBooks?

    I emailed a PDF to my iPad.
    Then opened it in iBooks.
    Now I want to copy part or all of the document into a Pages document.
    I can't find a way to get a Select or Copy menu to come up.
    I've tried tapping, double tapping, and holding my finger on the page?
    Thanks for any help!

    Hi,
    Copy the content of PDF file in Adobe Reader and paset it to MS Word then create PDF file from the Word file.
    This may not work for all PDF files as some PDF files are not created correctly or some content cannot be copied.
    Acrobat XI Pro has features to extract/delete/crop pages in PDF files and you can download it from www.adobe.com(Trial version- 30 days free). Or you can upgrade your subscription to Acrobat Plus and see more information at https://www.acrobat.com/acrobatplus/en/home.html
    Hisami

  • Copy and paste - can't copy parts of a SMS message

     I'm getting really frustrated with the copy part of copy/paste within a SMS. In the SMS - If I tap on any number or word = nothing happens (if nothing is underlined), If I tap on a number underlined = I get the option to phone or skype?? If I double click = nothing happens, If I do a long press I the options to:COPY MESSAGE TEXTFORWARD MESSAGECOPY MESSAGE TO SIM CARDDELETE MESSAGEVIEW MESSAGE DE TAILSADD STAR  If I want to copy some text (e.g. phone number, address, anything else) but not the whole SMS I cannot find a way to do it. Anyone else having this problem with SMS messages? Sometimes you need to extract info from the SMS to paste into an entry box on a website for example or to add to contacts etc. Can anyone help?  

    Hi and welcome to the community! Since you're new please be sure that you have checked out our Discussion guidelines.
    Unfortunately, it's not possible to copy parts of a text message in the pre installed messaging application. But if you press a number, you can open it with the phone application and copy the number from the dialer. And if you want to copy an URL, you can open the page and copy it from the URL-field.
    If you want parts from a text message, my best suggestion would be to copy the text into a notepad or similar and edit the text. Thereby, you can copy it with the text you want included.

  • Copying part of Library intact from Package contents?

    We have a problem with one of our disks in a 2006 Mac Pro and want to copy parts of the "package Contents" using Finder to allow import into Aperture using older Clone to restore new content into Aperture.
    1) What content from the "Package" should I copy in order to then import (? how?) in order to preserve the work done on some of the images such as ratings and cropping etc...?
    2) Notice that imgaes deleted in Aperture still remained in the Package contents. Is that because Aperture was not closed down properly before this incident happened or is this normal... keeping deleted images in the Package Content that have been deleted?
    Many thanks for help with this!

    Pretty much all the files/folders in the Aperture library are needed.
    It's not clear from your post just want the problem is. If the disk is bad how is that you are able to copy some of the library but not the whole thing? You should copy as mush as you can and see where you are after that.
    You could ditch the Previews and Thumbnails folders. Possibly the Aperture.aplib folder. A few others. But in order to import the remaining data into another library you need the old recovered data in a library that Aperture can open. You can't manually  merge the files into the other library.
    You can try this: Create a new empty Library, then replace the Masters and Database folders in the new library with those folders from the old library, then start Aperture while holding down the option and  comand keys and run Rebuild. If the library opens after that you should be OK.
    good luck

  • Can you copy/paste files from the Finder to Mail in Lion, or drag them onto the Mail icon in the Dock to create a new message and attach the files to it?

    Message title says it: Can you copy/paste files from the Finder to Mail in Lion, or drag them onto the Mail icon in the Dock to create a new message and attach the files to it?
    I can't find anything in the Knowledge Base that says these two options no longer work or still do.
    I do not have a system capable of running Lion, but I need to know the answer nonetheless.

    Gee, I don't know: "paste attachments mail Lion"? ;-)
    One further question, if I may: in Panther (which is where I've aggregated nearly 7 years of mail), if you copy more than one file in the Finder, switch to Mail, and paste the files into a new message, only the file names paste in. If you copy one file and paste it into a Mail message, you get the file, not just the name. Is that still true, or has that (IMHO) bug been fixed since 10.3.9?

  • How do I copy parts of layers from one AI doc into a new AI doc and keep/create same layer names?

    How do I copy PARTS of layers containing many objects from one CS5 AI (v.15.0.2) doc into a new CS5 AI doc and keep/create the same layer names?
    To start with, I have one fairly complex AI document with 100 layers,  with several hundred items in each layer. For example, one layer named "Stars" contains  400 separate stars (not grouped), another layer named "Crosses" contains 300 separate crosses, and a 3rd layer named "Text" contains 200 separate words (not outlined).
    If I select, by marqueeing a section of the image/artboard, some (but not all) of the individual items contained in the several layers, then  paste that selection into a new CS5 AI doc, I cannot get them to  create new layers of the same name. Instead they go into one general layer (e.g. "Layer 101") as a jumble of discrete, but unorganized objects (no layers or sublayers). In other words, I have lost the 3 main layers from which I selected a bunch of objects.
    Checking "Paste Remembers Layers" has no effect on this result. In fact "Paste Remembers Layers" does not remember layers at all. Only if I select ALL the items in the several layers will it paste those layers by those names into the new doc (or create new layers of the same names).
    Of course it is a COLOSSAL waste of time copying the ENTIRE document, then pasting the WHOLE thing into the new doc (with layers retained), then deleting the parts I DON'T need, so please don't suggest that as the solution.

    No Monica, nothing in Plug-ins other than the standard installed items (extensions, filters, formats, etc.). No 3rd-part clipboard extension on my computer that I'm aware of, either. All frustratingly basic. And my other CS5 Adobe programs appear to work well, at least to the extent that I am familiar with them.
    So, from what I can tell of the various comments (thanks to all of you), am I correct in thinking that it seems I can't, in fact, do what all of you can do (that is, copy some objects from some layers in one doc and paste into another doc preserving those same layers by name and organization, and each containing the correct objects from each original layer)?
    If so, that solves half my issue - "is it supposed to be possible to do it"; leaving just the other half - "why can't I do it too".
    I'll get those screenshots made and posted later just in case I haven't adequately described the issue, or y'all haven't understood it.

  • Help in copying part of threaded text in InDesign CS5

    When I copy part of a threaded text box that is linked to another text box in InDesign CS5 and then paste it to another location, the text from the first text box appears in the pasted version. The remaining text that was linked from the first text box to the second does not appear in the pasted new text box.

    Nor should it. You only cpoied what you selected, and the new frame is not threaded to anything.

  • How can I copy part of a larger PDF file and create a smaller one?

    How can I copy part of a larger PDF file and create a smaller one?

    Hi,
    Copy the content of PDF file in Adobe Reader and paset it to MS Word then create PDF file from the Word file.
    This may not work for all PDF files as some PDF files are not created correctly or some content cannot be copied.
    Acrobat XI Pro has features to extract/delete/crop pages in PDF files and you can download it from www.adobe.com(Trial version- 30 days free). Or you can upgrade your subscription to Acrobat Plus and see more information at https://www.acrobat.com/acrobatplus/en/home.html
    Hisami

  • How can i copy itunes from ext.hardrive t o mac itunes, when i try igot a question? (if i want to delete my old itune and copy my new itunes to finder)) not sure how to cmby bough itunes in finder

    PLEASE somebody....how can i copy itunes from ext.hardrive to mac itunes, when i try i got a question? (if i want to delete my old itune and copy my new itunes to finder)) not sure how to cmby bough itunes in finder.

    PLEASE somebody....how can i copy itunes from ext.hardrive to mac itunes, when i try i got a question? (if i want to delete my old itune and copy my new itunes to finder)) not sure how to cmby bough itunes in finder.

  • Copy alphabetically sorted items from Finder yet pastes them UNSORTED!!!

    This is weird, but if I copy some items from the Finder in list or column view (they show alphabetically sorted), they paste UNSORTED on Eudora or Word 2004, for instance. How to fix it, so that they are pasted also alphabetically sorted (A to Z)? Thanks.

    ApMaX wrote:
    Edit - Paste and match style, because if I select just Edit - Paste, then the file icons instead of the file names is what is pasted
    I used the helpful hint from above "convert to flat text (shift-command-T)"

  • How copy part of the array buffer from ColorFrame

    I want copy part of the color frame When I receive it.
    Is there way to do that without copy all the byte array first? (+ example)
    (Question similar to Kinect 1,
    but for kinect 2)

    if you access the raw data you can set offsets based not he width/height of the color frame(y*width+x). The c++ and managed api provide that as a function of the frame. These api's are used in some of the samples so review the code if you are
    unsure of the api use:
    c++ AccessRawUnderlyingBuffer
    https://msdn.microsoft.com/en-us/library/microsoft.kinect.kinect.icolorframe.accessrawunderlyingbuffer.aspx
    .Net c# - LockRawImageBuffer
    https://msdn.microsoft.com/en-us/library/windowspreview.kinect.colorframe.lockrawimagebuffer.aspx
    Carmine Sirignano - MSFT

  • Problem! I just copied my extern hdd to finder and tried to open my files when I get the message: "The Map "Pictures" can not be opened since you don´t have authority to  see it´s contents! What??? No one else has access to my computer....

    Problem! I just copied my extern hdd to finder and tried to open my files when I get the message: "The Map ”Pictures” can not be opened since you don´t have authority to  see it´s contents! What??? No one else has access to my computer....now I can´t open my 300 Gb on my hdd in my Macbook Pro. Help?

    I've had this happen a few times before. What I found works is repairing the permissions. To do so click on go and then to utilities. click disk utilities. In disk utilities select the drive and click repair permissions. It may take a little time but try accessing after that.

  • Why do my MAC Microsoft Office printouts always issue me an additional print copy of the Filename,   author, date, minutes, words  etc? It is wasting ink and paper.  What can I do to remove this?

    Why do my MAC Microsoft Office printouts always issue me an additional print copy of the Filename, author, date, minutes, words  etc? What can I do to remove this? It is wasting ink and paper.

    Yes but there's no point doing it here. As the Terms of Use make quite clear this is a User to User forum. It's Users like you talking to other Users. It's not a channel to communicate with Apple.
    Regards
    TD

  • Can no longer copy and paste filenames from the finder to other Apps?

    Did Leopard remove the ability to copy a file or folder name in the finder, and then paste that into a text editor?
    I have a need to copy file and folder names from the finder, then paste those names into BBEdit. I've been doing this for years. Now with Leopard, I can copy the file or folder names, and even see them in the clipboard of the Finder. But when I try to paste them into BBEdit, TextEdit, Word, Pages... nothing happens. And Paste is grayed out in the target application. As if I had never copied the item in the first place.
    Can anyone else copy filenames in the finder? Or do I have a system-specific problem?

    Never mind. Apparently there was something going wrong with the Finder. I ran Onyx, and things are back to normal now. I was concerned because I actually saw similar but not identical behavior on two Leopard machines. Running Onyx on the 2nd one now.

Maybe you are looking for

  • Clamshell iBook Won't Boot from Jaguar CD (v10.2.3)

    Branching off from a prior thread (https://discussions.apple.com/message/13222609#13222609) in which booting from an OS X CD was a potential solution to a problem, the problem encountered with the potential solution warrants its own thread. My machin

  • Javax.print problem: data not of declared type

    Hi all, I'm trying to print a simple text-only document with the below code but it keeps giving me an illegal argument exception. By the way, I've tried all the combinations of DocFlavor.*.* and SERVICE_FORMATTED.PRINTABLE and SERVICE_FORMATTED.PAGEA

  • Delete duplicate records

    Hi everyone, I am writing a statement to delete duplicate records in my data. For example: select identnr,datum,klokin,klokuit,count(datum) from fus_timesheets group by identnr,datum,klokin,klokuit having count(datum) > 1; Above code gives following

  • JTable: Easy groupable column headers with hideable columns

    Hi All, I have a requirement to make a JTable which displays columns with 2 values - a current value and an old one. The old value can be hidden or shown by user preference. The values are not editable. The 2 values have a single heading. I've been m

  • No boot, no logo, no sound, repeated "eject sound"

    Please help! :-) My Mac mini doesn't boot any more. Since yesterday. Out of a sudden. When pressing the power button, the mini seems to "try to eject" a CD. The "eject sound" is repeated endlessly. I tried to insert a CD, but this did not solve the p