Workflow and/ or script to rename finder items using a .txt or a .csv file as a reference?

Can someone assist me, I am looking for a workflow and/ or script that would allow me to rename finder items using a .txt or a .csv file as a reference for the new naming convention?

THANK YOU!!!! 
I have taken your recommendation and enabled the script menubar item.  I also tweeked the script as you recommended, I will play with both options to see which I prefer.   I thank you again for the quick turn around on this. 
If I am to understand your comment correctly about placing the .csv file in the same folder as the files to be renamed I should modify the script as such.
REMOVE:    
                    set csvFile to choose file with prompt "Select the CSV file." of type "public.text"
                    set workingFolder to (choose folder "Select the folder to be processed") as text
                    set fileList to (POSIX path of (files of folder workingFolder whose visible is true and name begins with "untitled"))
REPLACE WITH:     
                    set csvList to paragraphs of (read "/path/to/csvfile.csv")
                      set fileList to (POSIX path of (files of folder "/pah/to/folder" whose visible is true andname begins with "untitled"))
After reading this and attempting to modify it I am missing one piece of markup or the arrangement of the markup.
Please find the modified script with options:
-- change this to specify the correct csv delimiter
set splitDelimiter to ","
-- change this to specify the file name join character
set recombineDelimiter to "_"
-- choose the csv file
set csvFile to choose file with prompt "Select the CSV file." of type "public.text"
-- choose the folder
set workingFolder to (choose folder "Select the folder to be processed") as text
-- csv contents as list
set csvList to paragraphs of (read csvFile)
--set csvList to paragraphs of (read "/path/to/csvfile.csv")
tell application "System Events"
-- list of files in alphabetical order
     set fileList to (POSIX path of (files of folder workingFolder whose visible is true and name begins with "untitled"))
  -- set fileList to (POSIX path of (files of folder "/path/to/folder" whose visible is true and name begins with "untitled"))
     repeat with i from 1 to count of fileList
-- get a file from the file list and note its extension
          set currentFile to file (item i of fileList)
          set fileExtension to name extension of currentFile
-- get a line from the csv list, split it at the delimiter,  and recombine it
          set {oldTID, my text item delimiters} to {my text item delimiters, splitDelimiter}
          set newFileNamePieces to text items of (item i of csvList)
          set my text item delimiters to recombineDelimiter
          set newFileName to newFileNamePieces as text
          set my text item delimiters to oldTID
-- write the new name back out to the file
          set name of currentFile to (newFileName & "." & fileExtension)
     end repeat
end tell

Similar Messages

  • File Move and Rename Workflow and/or Script

    This seems to be a simple workflow to create, but it isn't working for me. I want a workflow and/or script that will move screenshots from my desktop and place them into a folder. Secondly, I want these images to be renamed from "Picture #" to "Screenshot #" when placed in the folder. I also want future images placed in this folder to be named sequentially without any problems. For instance, if Screenshot 1, Screenshot 2, and Screenshot 3 are present in the folder after the workflow is ran once, the next file should be named Screenshot 4 when the workflow is ran again. Can anyone offer any assistance in this matter? I would greatly appreciate it.

    If all you are doing is renaming and moving screenshots, then a regular AppleScript should do. Copy and paste the following script into the Script Editor and save as an application (uncheck the Startup Screen option). When it is first run it will ask for the destination folder, but after that it will use the same folder (until the script is recompiled, anyway).
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px; height: 340px;
    color: #000000;
    background-color: #FFDDFF;
    overflow: auto;"
    title="this text can be pasted into the Script Editor">
    -- rename and move screenshots from the desktop to the specified folder
    property ScreenshotFolder : (path to desktop) -- the default folder where the screenshots are created
    property ScreenshotExtension : ".png" -- the default screenshot extension
    property DestinationFolder : missing value -- the folder to move to
    on run
    if DestinationFolder is missing value then set DestinationFolder to (choose folder)
    tell application "Finder" to get files of ScreenshotFolder whose name begins with "Picture " -- get screenshots
    repeat with AnItem in the result -- do stuff with each item
    GetUniqueName for ("Screenshot" & ScreenshotExtension) from DestinationFolder
    tell application "Finder"
    set the name of AnItem to the result -- rename
    move (ScreenshotFolder as text) & the result to DestinationFolder -- move
    end tell
    end repeat
    end run
    to GetUniqueName for SomeName from SomeFolder
    check if SomeName exists in SomeFolder, creating a new unique name if needed
    parameters - SomeName [text]: a name.extension to check for
    SomeFolder [mixed]: a folder to check
    returns [text]: a unique name
    set {Counter, Divider} to {"01", " "}
    set Here to -(offset of "." in ((reverse of text items of SomeName) as text)) - 1
    set TheName to text 1 thru Here of SomeName
    if Here is -1 then -- no extension
    set TheExtension to ""
    else
    set TheExtension to text (Here + 1) thru -1 of SomeName
    end if
    set NewName to TheName & Divider & Counter & TheExtension -- always add a suffix
    tell application "System Events" to tell (get name of items of folder (SomeFolder as text))
    repeat while it contains NewName
    set Counter to text 2 thru -1 of ((100 + Counter + 1) as text) -- increment suffix with leading zero
    set NewName to TheName & Divider & Counter & TheExtension
    end repeat
    end tell
    return NewName
    end GetUniqueName
    </pre>
    I added a leading zero to the number suffix so that the items sort properly. Note that if one of the renamed items is removed, a new screenshot will take it's place (the suffix starts at the beginning each time). If this isn't desired, the script can be tweaked to remember the last suffix number.
    HTH

  • Rename Finder Items from Automator doesn't work correctly!

    I made a rename finder items in Mac OS X 10.4 by just using rename finder items task and save as a plug in for finder. It was working fine. I tried to use it in 10.5, but it doesn't really change the names. I created a new one or even tried to modify the workflow, but it still not working. Can someone verify the issue? Thank you.

    I can verify the issue, but I have no solution. Very frustrating, as I used to batch rename all the time in just the same way.

  • Rename Finder Items with Automator in Leopard

    I used following automator actions to rename all files contained in selected folders in Mac OS finder:
    1. Get Selected Finder Items
    2. Get Folder Contents (repeat for each subfolder found option on)
    3. Rename Finder Items (Add Text before name, Show action option on)
    First two actions were executed flawlessly. Unfortunately after keying in text to be added in front of every file name in text field of popup window on execution of last action, no file name was changed. Then I realized that same actions performed in automator application instead of invoking through Finder's contextual menu worked as expected. So the problem seem to be related to initialization of text value in text field of the action.
    I decided to try with new variable feature introduced in Leopard version of automator. Clicking on Variables button next to Actions button in menu bar of Automator, then select following item:
    Library > Text & Data > New Storage
    I managed to provide a text value for the New Storage variable through "Library > Text > Ask for Text" and "Library > Utilities > Set Value of Variable" actions, but text field in Rename Finder Items action seem to reject the New Storage variable completely. So the attempt to provide text value to the Rename Finder Items action through user initialized variable failed without reason.
    May I know how can I make use of variables to set text fields in Rename Finder Items action ? Is the above mentioned failure a confirmed bug of Leopard waiting to be fixed by Apple (after one whole year of beta testing !!) ? Thanks in advance.

    I figured out a way to use variables in the Rename Finder Items.
    In my case I want to rename the files to a sequential name. I can't link the variable to the "New Name" box in the Automater GUI.
    But it helps to know that that the Automator is just creating an XML file and you can edit this directly.
    To do this, create the Automator workflow and save it. Give the variable some distinct name like "myVariable".
    In Finder, right click the Automator file and select Show Package Contents. Within this folder go to Contents and find the document.wflow file. This is the XML file, so open it with TextEdit or something.
    Search the file for your variable name. The first instance of it should be in a section that starts with <key>variables</key>. All the variables will be listed here. Each variable has several lines to define it. The first will be the UUID. The UUID will have a line that is something like: <string>BD464B7A-ACDE-4A63-B595-FAF1DA6DE26E</string>. The BD464B7A-ACDE-4A63-B595-FAF1DA6DE26E is how Automator refers to your variable. Search the file for this UUID string and you will see. Whenever Automator wants to insert the variable, it will enter $(BD464B7A-ACDE-4A63-B595-FAF1DA6DE26E).
    Copy this string, with the $() surrounding it. Close the wflow file. Now you can go back to Automator itself and paste it wherever you want your variable to appear, even if you can't normally insert the variable into that field.

  • Rename finder item withouth user to choose find string.

    Hi,
    I've built an automator workflow in wich I create a standard folder /w subfolders. Automator then renames the folders, by rename finder item with replace text.
    The new name is a projectname an user can give in. But I don't want the user to change the find string. Is there a way to work this out?
    I've tried to do an ask for text, but I don't know to how I can put the result into the replace field?
    Thx,
    Marlon
    Powerbook G4 (1Ghz)   Mac OS X (10.3)  

    I figured out a way to use variables in the Rename Finder Items.
    In my case I want to rename the files to a sequential name. I can't link the variable to the "New Name" box in the Automater GUI.
    But it helps to know that that the Automator is just creating an XML file and you can edit this directly.
    To do this, create the Automator workflow and save it. Give the variable some distinct name like "myVariable".
    In Finder, right click the Automator file and select Show Package Contents. Within this folder go to Contents and find the document.wflow file. This is the XML file, so open it with TextEdit or something.
    Search the file for your variable name. The first instance of it should be in a section that starts with <key>variables</key>. All the variables will be listed here. Each variable has several lines to define it. The first will be the UUID. The UUID will have a line that is something like: <string>BD464B7A-ACDE-4A63-B595-FAF1DA6DE26E</string>. The BD464B7A-ACDE-4A63-B595-FAF1DA6DE26E is how Automator refers to your variable. Search the file for this UUID string and you will see. Whenever Automator wants to insert the variable, it will enter $(BD464B7A-ACDE-4A63-B595-FAF1DA6DE26E).
    Copy this string, with the $() surrounding it. Close the wflow file. Now you can go back to Automator itself and paste it wherever you want your variable to appear, even if you can't normally insert the variable into that field.

  • RENAME FINDER ITEMS

    - I am using the function RENAME FINDER ITEMS to rename hundreds of files. It is possible to use wild chars in the FIND field ?
    - All my file names start with date (example: 2010-04-10 xxxx.yyy) and i want to rename it to xxxx.yyy.
    thank you,
    Paulo

    I don't think Automator can do this task for you. Consider Name Mangler instead: http://manytricks.com/namemangler/.

  • IMac: I try to save a file and get 'the action "Copy Finder Items" encountered an error.  Check the action's properties and try running the workflow again.'

    I keep on running into this when I try to save a download file. Any help would be appreciated.
    'The action "Copy Finder Items" encountered an error.  Check the action's properties and try running the workflow again.'
    I tried clicking the button to change the save but that has no effect.

    Hi All,
    I am having same issue too.  Can anyone you advise?  Thank you.

  • How to display the current name when renaming Finder item

    Is there any way to get Automator to display the current name of a Finder item when renaming an item?
    I want my users to be able to copy and rename a folder template but I want to display the folder template's current name as a default in the renaming dialogue window, so the user follows the correct naming format.

    Since you've already hacked into it, if you've got developer tools installed, it is most likely in the nib file that is in the English project folder in the Resources.
    I don't know what further implications that will have on the app in general, though.
    If you are a little adept at applescript, you may want to create your own Applescript Studio app to do this instead of Automator. Also, take a look at Platypus to make a wrapper around you applescript instead of AS Studio.
    Message was edited by: Barney-15E

  • Import List Items with Managed Metadata Field from CSV File

    Hello,
    I try to import list items from a CSV File. Most of the fields are populating correctly except the Managed Metadata Field. I found multiple examples on how to set Managed Metadata Fields with Powersehll, but unfortunately I couldnt get it running.
    The CSV File holds values for the Metadata Column, this value should be checked against the Metadata in the Termstore. If this Term is existent, then it should set the fields value, if it is not existant then it should add the term from the CSV File to the
    Term Set in the Term Store. Can anybody give me a tip on how to do this? This is what I have, where Line 4 holds the Metadata:
    $Siteurl = "http://siteUrl"
    $Rootweb = New-Object Microsoft.Sharepoint.Spsite($Siteurl);
    $Webapp = $Rootweb.Webapplication
    $listName = "Catalogue"
    $listWeb = Get-SPWeb $Siteurl
    $list = $listWeb.Lists[$listName]
    $pfad1 = "c:\temp\Servers.csv"
    $content = import-csv -Delimiter ";" -Path $pfad1 
    foreach ($line in $content) {
    $newItem = $list.Items.Add()
    $newItem["Field 1"] = $line.1
    $newItem["Field 2"] = $line.2
    $newItem["Field 3"] = $line.3
    $newItem["Field 4"] = $line.4
    $newItem.Update()
    write-host $line.Title imported
    Thanks!!

    Hi Jimmie,
    From your description, when importing list from csv to SharePoint site, you would like to compare if Managed Metadata column exists in term store, and return yes value, if not, add it to term store.
    That might need script to achieve. You need to import list at first, then get value from term store, and compare with the list. Change the list field per comparison result, then add new value to term store.
    However, there might some workaround to meet your requirement. Not surly understand, so I find some references for you:
    If you would like to export Term Set to CSV from SharePoint 2013, then you could compare it:
    http://gallery.technet.microsoft.com/office/PowerShell-for-SharePoint-a838b5d0#content
    If you would like to query SharePoint 2013 Managed metadata term store using JavaScript:
    http://sharepoint.stackexchange.com/questions/60045/query-sp2013-managed-metadata-term-store
    http://stackoverflow.com/questions/13858962/getting-all-the-term-stores-in-sharepoint-2010-web-services-or-client-side-obje
    If you would like to synchronize, import or copy term store & managed metadata in SharePoint between environments:
    http://www.matthewjbailey.com/synchronize-import-or-copy-term-stores-managed-metadata-in-sharepoint/
    Regards,
    Rebecca Tu
    TechNet Community Support

  • Automator Rename Finder Items NOT working in Leopard

    I used to be able to Replace Text in filenames, as you would expect with Automator, now my old or new Automator actions don't work for this, whether I run them as a Finder plugin or from the Automator Run button...
    Anyone else have this problem, or better yet success?

    The real problem here is, why does the Finder have to be so ********! Why all this trouble just to change filenames?!?! Why use automator to do something so simple?!?! I have to use but I hate it!
    Please, despite all the Windows problems and faults (and I hate Windows and love Mac), they have a better file manager then we do, because the explorer is a good tool unlike the finder! Why can't we just choose the items and do some "rename" option, or just select all, press "enter" and write what we want (doing a sequential rename by default).
    Come on, if windows explorer can do this, why can't we?!?!?
    The automator should be used to more advanced stuff, not to just simply rename items...

  • Just done the 'Erase and Install', I can't find the Hard Drive I backed up my files on?

    I have just done the 'Erase and Install' process, but before I did, I backed up my files to an External Hard Drive using Time Machine. I have now restored my Mac and gone through the Erase and Install process, but now, when I plug in my external hard drive, I cant find it anywhere? I've tried quite a few things, but no luck! Also, what has happened to iMovie and iPhoto and all those Applications?! They have dissapeared!

    GeorgeRollo wrote:
    I have just done the 'Erase and Install' process, but before I did, I backed up my files to an External Hard Drive using Time Machine.
    That should mean that all of your data on the MBP is backed up to an external HDD.
    - Yes, should be. But when I plug it in the Mac, no menu or pop up comes up. Showing what to do next.
    I have now restored my Mac and gone through the Erase and Install process, but now, when I plug in my external hard drive,
    If you restored your internal drive with Time Machine, did you then ERASE and install?  What did you erase and what were you installing?  What is on the external HDD that has the Time Machine backup on it?
    - I talked to the Customer Support and they said just erase the Startup Disk or something? So I did. Because I basically just wanted to restore my Mac.
    I cant find it anywhere?
    What is it?
    - The External Hard Drive when I plug it in.
    I've tried quite a few things, but no luck!
    What are 'quite a few things'?
    - Things that I have researched like going into 'Finder' then going into 'Preferences', 'General', then ticking 'Hard Drive' under the option of 'Show these items on the desktop:'
    what has happened to iMovie and iPhoto and all those Applications?! They have dissapeared!
    I would think that they should be on the Time Machine backup (assuming the external HDD has not been erased) if not the internal HDD.
    - Hopefully if I can figure out this.

  • Mail Can't find items using search box

    After import from my 10.5 iMac G5 to my 10.5iMac Intel I can not retrieve email data using the mail's search box. Any ideas?

    Here's what I get (xxx = ISP name):
    INITIATING CONNECTION May 13 09:11:56.494  -- host:mail.xxx.net -- port:25 -- socket:0x0 -- thread:0x7fa72ac92780
    CONNECTED May 13 09:11:56.605 [kCFStreamSocketSecurityLevelNone]  -- host:mail.xxx.net -- port:25 -- socket:0x7fa72be13640 -- thread:0x7fa72ac92780
    READ May 13 09:11:56.695 [kCFStreamSocketSecurityLevelNone]  -- host:mail.xxx.net -- port:25 -- socket:0x7fa72be13640 -- thread:0x7fa72ac92780
    220 dm0205.mta.everyone.net ESMTP EON-AUTHRELAY2
    WROTE May 13 09:11:56.696 [kCFStreamSocketSecurityLevelNone]  -- host:mail.xxx.net -- port:25 -- socket:0x7fa72be13640 -- thread:0x7fa72ac92780
    HELO [192.168.1.4]
    READ May 13 09:11:56.789 [kCFStreamSocketSecurityLevelNone]  -- host:mail.xxx.net -- port:25 -- socket:0x7fa72be13640 -- thread:0x7fa72ac92780
    250 dm0205.mta.everyone.net
    WROTE May 13 09:11:56.792 [kCFStreamSocketSecurityLevelNone]  -- host:mail.xxx.net -- port:25 -- socket:0x7fa72be13640 -- thread:0x7fa72ac92780
    QUIT
    INITIATING CONNECTION May 13 09:11:58.940  -- host:mail.xxx.net -- port:25 -- socket:0x0 -- thread:0x7fa72ac63a60
    CONNECTED May 13 09:11:59.039 [kCFStreamSocketSecurityLevelNone]  -- host:mail.xxx.net -- port:25 -- socket:0x7fa72badbe30 -- thread:0x7fa72ac63a60
    READ May 13 09:11:59.129 [kCFStreamSocketSecurityLevelNone]  -- host:mail.pemtel.net -- port:25 -- socket:0x7fa72badbe30 -- thread:0x7fa72ac63a60
    220 dm0205.mta.everyone.net ESMTP EON-AUTHRELAY2
    WROTE May 13 09:11:59.132 [kCFStreamSocketSecurityLevelNone]  -- host:mail.xxx.net -- port:25 -- socket:0x7fa72badbe30 -- thread:0x7fa72ac63a60
    HELO [192.168.1.4]
    READ May 13 09:11:59.223 [kCFStreamSocketSecurityLevelNone]  -- host:mail.xxx.net -- port:25 -- socket:0x7fa72badbe30 -- thread:0x7fa72ac63a60
    250 dm0205.mta.everyone.net

  • Hi I have a message saying a file on my accounts progaramme is damaged and cannot be opened. It says use the Recover command to recover file. How do I do this please.

    Hi I have a Macbook. Yesterday and quite often it freezes and runs really slow. But I was working on my accounts programme and it froze and now that file won't open. It says to do the recover command on the file, but not sure how to do it!
    Version is Yosemite 10.10.1 Macbook 13inch late 2009. my accounts programme is Instant Admin. Please help.

    Hi pennsmith67. You have the program Instant Admin and it wants you to do a recover. You would have to open the program or the installer to see how to do this. You might have to reinstall it. As far as Yosemite being slow, one thing you could do is add more ram. You can run as much as 8Gig's of ram with your Macbook. as to running slow read this. http://support.apple.com/kb/PH19031

  • "Run Workflow" action in Automator does not "Ask for Finder Items"

    So I have a workflow called step_1 that does a bunch of stuff . . . in essence, it "Asks for a Finder Item" and then runs some Python shells and then outputs an Applescript format list {'item_1','item_2','item_3'}
    I'm trying to use this workflow in another workflow so I selected "Run Workflow" in Automator and located my original workflow step_1 but when I run it, the process goes straight through the workflow and doesn't "Ask for Finder Items" so i'm sure it doesn't do anything else in the workflow either.  It doesn't give me an error, it just pretty much bypasses everything within the workflow and it's pretty annoying.
    Any idea on how to get my workflow to work using "Run Workflow" ?

    Never tired Run Workflow before so as as a test I rn these two
    and the Ask for Finder items in the called workflow ran OK.
    Note this was run  from Automator. One thing I did see was that the Ask for finder items window did not come to the front and I had to look under my open windows to see it.

  • Automator - how reset Finder Items?

    I want to to defrag a big file, so I have thought to copy the file in an external disk, than rename the file in external disk and copy to directory in which there is the file to defrag.
    Than revert to the original name the file in the external disk.
    In this way I have a copy of the file in external disk and the original file and the file copied in HD.
    I do that to avoid failure of external Hard Disk that could have the result to destroy the original file if this happen during the copy from external to internal HD.
    I have made a workflow that do this:
    1) Get Specified Finder Items (pictures/file)
    2) Copy Finder Items (to DK1)
    3) Rename Finder Items (DK1/file to DK1/filecopy)
    4) Copy Finder Items (to pictures)
    5) Get Specified Finder Item (DK1/filecopy)
    6) Rename Finder Items (DK1/filecopy to DK1/file)
    The problem is that in the 5 step the item passed to the 6 step are two (pictures/filecopy and DK1/filecopy).
    I want only DK1/filecopy.
    I have seen that Item passed to various step are:
    1) Get Specified Finder Items (pictures/file) >>passed picture/file
    2) Copy Finder Items (to DK1) >>passed DK1/file
    3) Rename Finder Items (DK1/file to DK1/filecopy) >>passed DK1/filecopied
    4) Copy Finder Items (to pictures) >>passed pictures/filecopied
    5) Get Specified Finder Item (DK1/filecopy) >>passed two pictures/filecopied and DK1/filecopied
    6) Rename Finder Items (DK1/filecopy to DK1/file) >> in error
    I have have tried to make two workflow one with the step from 1 to 4 and another with the step 5 and 6.
    If they run separately all is ok, but if they run in a single workflow (that is made with the step from 1 to 4 and the 5 step that recall the second workflow) happen the same thing that I have described before.

    Stanley Horwitz wrote:
    I have been working with Macs since 1986 and in the IT industry full time since about the same time and I honestly have no clue what you are attempting to do. What does "defrag a file" mean and why do you want to do that?
    I want to copy a file to an external device, so system, copying file, write this without fragmentation, and then copy to original location.
    In this way the result is to have the file unfragmented.
    If you want to defrag your disk, by far the easiest and quickest way to do that is to take another disk drive that's as big or bigger in capacity as the disk you want to defrag, then format that disk, then simply use your favorite disk cloning tool to copy the contents of the disk you want to defrag to the other disk. The copying process to a newly formatted disk will write the data in an optimum manner onto the disk without any fragmentation on the destination disk. You can then, if you so desire, reverse the process and clone the cloned drive back to the original drive and you will end up with two defragmented disks with the same data on them. The biggest benefit to this strategy is that you get a complete backup of the contents of the disk.
    OK, but I only want defrag 1 file, not all the disk.
    If You see, I want the same manner that You suggest for the entire disk, applied only to 1 file.
    There are also several utilities that will do disk defragmentation such as TechTool Pro and Disk Warrior. I think though that in all but the most extreme cases, it is a wast of time to use those utilities to defragment a disk. In fact, in most cases that I have seen on home Macs, the benefits of defragmentation are minimal at best, which is why I suggest simply doing a backup of the disk to another disk, because the big benefit there is that you have a fresh backup which is far more important in most cases than defragmenting a disk.
    OK, I don't want defrag utilities, because I am not confident in the process.
    For backup I use regularly Time Machine on two external disks.
    All the matter is only to know if there is a manner to tell Automator wich is the file to use during the workflow.
    Thanks.

Maybe you are looking for