Use AppleScript to remove a specific word/phrase from Multiple Folder names

Within one of my folders I have hundreds of Folders that have specific words or phrases in the names I would like to remove using apple script.
For instance if the folder names all contain the word "Default" what script could I write to remove "Default" from the names of all folders with it in the name.
So, if folder is named "bobDefault"  how could I get it to remove Default and keep bob and then continue on the rest of the folder names within the main folder.  I appreciate any help you may provide.

The following should do the trick (if there's always a space before the left parenthesis):
set theFolder to choose folder
tell application "Finder" to set theNames to name of folders of theFolder
set theNewNames to {}
repeat with thisName in theNames
     set P1 to offset of "(" in thisName
     set P2 to offset of ")" in thisName
     if P1 * P2 > 0 then
           try
                 get (text (P1 + 1) thru (P2 - 1) of thisName) as integer
                 set theString to text P1 thru P2 of thisName
                 set thisName to replace(space & theString, "", thisName)
           on error
                 -- no change
           end try
     end if
     copy thisName to the end of theNewNames
end repeat
tell application "Finder" to repeat with k from 1 to (count theNames)
     try
           set name of folder (item k of theNames) of theFolder to (item k of theNewNames)
     end try
end repeat
on replace(A, B, theText)
     set {TID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {A}}
     set {theTextItems, AppleScript's text item delimiters} to {text items of theText, {B}}
     set {theText, AppleScript's text item delimiters} to {theTextItems as text, TID}
     return theText
end replace

Similar Messages

  • HT4207 how can I remove a specific gmail account from my ipad 4?

    How can I remove a specific Gmail account from my ipad 4?

    Assuming you are not syncing with iCloud and you mean, syncing with iTunes only...(you can only use one or the other for syncing to prevent duplicates)
    iTunes -
    - Open iTunes on your Mac. Connect your iPad. Then click on your iPad (either its name or just "iPad"), then click the info tab (right above the photo of an iPad in the middle). From here you can select sync contacts, then sync groups, and select the groups you want and choose Apply/Sync in the bottom left corner.
    iCloud -
    - With iCloud if you just sign into iCloud in System Preferences and turn on Contacts, it will prompt to merge all of your contacts that are not already syncing with Gmail or Yahoo!, etc. so there really isnt a way to pick and choose as much with that.
    - However if you really want to use iCloud and not iTunes, you could import the contacts that you want into iCloud.com, but you would need to export them from your Contacts App on your Mac and then import them into iCloud (VCard / .VCF is the format you want).
    * Exporting the contacts from your Mac Contacts Application --> http://mac.tutsplus.com/tutorials/app-training/contacts-101-a-beginners-guide-to -contacts-on-os-x/ (further down the page)
    *Importing contacts into iCloud.com - http://support.apple.com/kb/PH3605
    **NOTE - Remember if you do the import into iCloud.com method, DO NOT sign into System Preferences > iCloud, and choose to MERGE contacts. If you do this later, all of your contacts will merge with iCloud and you will have duplicates of this group.
    I hope this isnt too confusing. Have a good night!

  • Can I use Visual Basic to covert form user data from multiple .pdf files to a single .csv file?

    Can I use Visual Basic to covert form user data from multiple .pdf files to a single .csv file?  If so, how?

    You can automate Acrobat using IAC (InterApplication Communications), as documented in the Acrobat SDK. Your program could loop through a collection of PDFs, load them in Acrobat, extract the form data from each, and generate a CSV file that contains the data.
    Acrobat can also do this with its "Merge Data Files into Spreadsheet" function, but this is a manual process.

  • Can I use Apple Configurator 1.6 to install Apps from multiple iTunes accounts on 30 iPads

    Can I use Apple Configurator 1.6 to install Apps from multiple iTunes accounts on 30 iPads in South Korea?

    Thank you again.  I am actually just using a single computer at thsi time but will be setting up a Mac Mini in a day or so.
    I actually believe I authorized my Mac Book for both my wife and my iTunes account.  Yesterday when I hooked her iPhone up it told me that my computer was not authorized to download an app, i had to authorize this macbook. 
    So if the Apps from both iTunes account  is on my Mac Book and I hook up my iPhone it will allow my to transfer the apps from my computer to my iphone?  So lets say I am logged into iTunes account #1 and I try to use an app from iTunes account #2 will I have to do anything special?
    Again thanks

  • Using Content Query webpart for specific Document library with multiple managed metadata - Document with multiple metadata tags not showing up

    Hi,
    I am having an issue where when I insert a Content Query webpart into a page, and filter to managed metadata, all the right documents show up except one document that happens to have two metadata tags attached to it.  The content query webpart is set
    to only look through a specific document library.  I'm not sure what I am doing wrong.
    Here is the one document with two metadata tags:
    Below is the Content Query:

    Hi,
    As I understand, you did not get the results with multiple metadata tags through Content Query web part in SharePoint 2013.
    Check things below:
    1. Check if you have set the item limit more than the display items in Presentation section of the web part. If the item number more than item limit, the rest items will not show.
    2. Check if the item you cannot find uses the content type you have set in the content type section of content query web part.
    When you edit the properties of the item, you will see the content type the item is using.
    Best regards
    Sara Fan
    TechNet Community Support

  • Can I remove a specific dated backup from time Capsule?

    Sorry for the long story - but I have tried to provide as much detail as possible as to what is going on...
    Sadly Lion has been a royal pain in the perverbial for me. It is slow (on a Macbook pro that is still within its warranty period so I don't believe that Hardware can be blamed - especially with upgraded ram and a 7200rpm drive) I recently got so frustrated with its clunkyness that I tried reinstalling on a new HDD and booting off that. Showed improvement (clean install vs upgraded and less apps etc slowing down the OS - however it is nowhere near what Snow Leopard was). But while I was at it I did something stupid. In hindsight very stupid - but balls to Apple for putting me in this situation and balls to Apple for letting me do it with no warning about the consequences...
    I connected my old HDD via firewire and tried to access my files that are on it - I couldn't initially as my newly installed user did not have permission. Easy - Add the new user to permissions for folder concerned - apply to enclosed - done - Achieved what I wanted. Files accessed - test complete - sadly I will have to reinstall a clean lion and transfer my files over (restore from time capsule).
    Two Major problems have surfaced. The first is directly related to the topic, the second I might try to repost in an appropriate section...
    1) What I didn't think about is as soon as I modified the permissions Time Capsule treats all the files in that folder as being modified. So it has backed up an entire new version of every file in that folder - a few hundred GB. That has chomped out 10-20% of my Time Capsule. I have no need for these backups and want to delete - say - every back up made since last Sunday when I committed the dirty deed. Seems minor - but this is a major compromise to my current arrangement.
    2) I have MAJOR permissions issues now. Firstly my Aperture library (which was in the folder with added user in the permissions) is fried. Can't be repaired/rebuild or anything. Lion wont do anything so useful as to tell me why - just get the colourwheel of death and the aperture library NEVER opens. Balls to Apple for allowing this to happen so easily. Second I tried to restore the entire pictures folder from Time Machine. It tells me I don't have permission??? WHAT. Double Balls. These are my freakin files - created by this user on this MBP on this install of Lion. I can't see how adding a user can suddenly prevent a long standing user from accessing their files from within their account. By the way the new install on the new HDD is no longer in play - all I am trying to do is continue to use my MBP the way I was before I did the test install.
    My long running affinity for Mac is rapidly waning - I have wasted countless hours trying to regain access to ALL of my pictures - 14 years worth. 1000's of images. I cannot access them on my MBP, Can't restore them from Time Machine. This is the worst computing experience of my life.
    I have tried booting from recovery, repairing permissions etc etc etc. Nothing mainstream solves this.
    Does anyone have some wisdom to address my conundrum - I am seriously desperate here... I have genuinely decided that I will not waste the upcoming long weekend ******* around with this - I would rather forget my 14 years of stored memories and just get on with life... If unsolved by this Friday I will sell my Macbook Pro and iPad and initiate my own version of the post PC world - no computer at all - currently it is doing nothing but wasting my time.

    jameski wrote:
    My only concern about resetting premissions (and ACL???) is that it will exacerbate my backup disk space wastage issue as it will result in full backup of my entire home folder (about 400GB).
    Yup, if you changed the permissions on everything in your home folder, that will change them all back, so they'll all be backed-up again. 
    That will leave me with about 1.2TB of a 2TB TC used up with backups (currently should be about 500GB) - my plan was to have about 1.5TB of my TC available to use for files in the medium term until the need for more backup space pushed me to invest in another drive. TC's are just too expensive to waste like this.
    Mixing backups and other data on the TC's internal HD will, eventually, cause conflicts.  But see #Q3 in Using Time Machine with a Time Capsule for some possible workarounds.
    If I do a complete restore from TM (entire account)
    You can't do that.   You can't restore an entire home folder via the "Star Wars" display, because the home folder and default sub-folders (Desktop, Downloads, Pictures, etc.,) are protected.  You'd have to restore the contents of the sub-folders, a rather tedious process. 
    You can do a "full system restore" (OSX, apps, all user accounts & home folders), via a different procedure (Time Machine - Frequently Asked Question #14).
    to the day before this shambles started - will time machine treat my restored account as a modification of all files and try to back up a fresh copy of everything on the basis that it has been modified - or is it smart enought to realise what I have done and carry on doing only incremental backups?
    Anything you restore via the "Star Wars" display is considered as changed, so will be backed-up.
    A full system restore (usually) results in only an incremental backup, but TM does a "deep scan" to compare everything on your system to the backups, to see what's different.  That will find that everything in your home folder has changed, so back it all up anyway.
    If yes I will likely put all my historical backups onto a cheap 500GB drive and put it in a drawer and start new backups on TC
    Good plan.   You probably know you can always view and restore from those, via the Browse Other Backup Disks option, per #17 in the FAQ.
    After you do that, in theory, you could run the user home folder permissions reset, delete all the backups made after the original permissions change, then force a "deep scan" so the only differences found would be files that really are new or changed; but that's tedious, error-prone, and "iffy."
    Are backups via TC inherently substantially slower than say to firewire drive?
    Oh, yes, absolutely.  Here's a very rough comparison of full backup speeds (see #29 in the FAQ for details):
    There's a lot of variation depending on your hardware and setup, of course.
    I am running my TC through gigabit ethernet as wifi (despite having an ethernet extended AEP in my office) is too slow. I simply cannot get over the serious loss of performance since Lion and more recently the introduction of a TC. It is dire!
    Some folks report WIFI backups slower under Lion vs. Snow Leopard, some think it's faster, others (including me) don't see much difference. 
    However, it really shouldn't make a whole lot of difference for normal incremental backups, as they should be relatively small and quick in most cases, and shouldn't have much impact on performance.  You might want to check the sizes of your backups -- if they seem too large considering what you've changed, see #D4 in Time Machine - Troubleshooting.  If the sizes are reasonable, but the backups are still slow, or other performance seems to suffer, see #D2 there.
    Are these your only backups?  If so, consider keeping "secondary" backups, to avoid having "all eggs in one basket."  See #27 in the FAQ for some suggestions.

  • How to delete a specific file type from a folder

    Hi,
    I have folders with lots of zip or rar files, once I decompress those I want to delete the compressed files specifically. Is there any way I could manage that through Automator?
    Thanks in advance.

    Thanks Niel for the script, unfortunately I am too ignorant about running these on my own, I did save it in my user script library, but I would need instructions to run it. I would be really grateful.
    I did try making up my own workflow using the given actions in Automator, the first action was to 'find specific files in finder' ending with .zip and .rar and then choosing another action which 'moves selected files to trash'. Unfortunately it ended up running only if I specify the path to the specific .zip file, which defeats the purpose. Any suggestions on the proposed workflow? Thanks in advance.

  • OK to remove MacOSXUpdCombo10.6.6.dmg from Downloads folder to free disc space?

    To free disc space I've been removing old files.  MacOSXUpdCombo10.6.6.dmg is by far the largest, at 1 GB.  I seem to recall using this file when I had to revert back to 10.6.6 after having font problems with 10.6.7.  I believe it's OK to just remove it to a backup source, but want to check before doing that, just in case.  Thanks for your council and any enlightenment on the function of such update dmgs, once they've been used.

    IMHO you have a more serious problem here. If 1 GB is going to make a difference in the amount of free space you can notice then your disk is probably too full and you should be looking for more drastic solutions to gain free space such as deleting your files.
    Allan

  • How to user PowerShell -replace to remove the dreaded em dash from a file name?

    I have a bunch of .msg files in a directory and want to zip them up (to send them to our spam filtering company), but I keep getting errors on file names that contain the em dash (—).  I believe it's (char)0x2014.
    [edited]... the correct syntax is [char]0x2014.
    I wish to eliminate the em dash in the file name but I can't seem to find anything on the web about replacing em dashes.  When I paste '—', PowerShell replaces it with a '-'.
    I found this neat function that does a great job replacing multiple characters within a string.
    http://powershell.com/cs/blogs/tobias/archive/2011/04/28/multiple-text-replacement-challenge.aspx
    I am using the below code for my string replacement.
    Thank you for your help.
    function Replace-Text {
    param(
    [Parameter(Mandatory=$true)]
    $text,
    $replacementlist = "(-,,',,%,,$,,@,,#,,&,,’,"
    Invoke-Expression ('$text' + -join $(
    foreach($e in $replacementlist.Split(',')) {
    '.Replace("{0}","{1}")' -f $e, $(
    [void]$foreach.MoveNext()
    $foreach.Current)
    $path = '<path>'
    Get-ChildItem -Path $path | Rename-Item -NewName {(Replace-Text $_.Name).trim()}

    Here is a simple filter that will strip out all nonprintable chanracters.
    $newname=$file.Name -replace '[^a-zA-Z\.]'
    I just tested it on Win 7 which supports has a Unicode filesystem and it successfullstrips the bad characters.
    We also need to do this on files uploaded to SharePoint and OneDrive.
    The ~ and other similar characters are not allowed in may systems.  You should keep a translation log and tag all renamed files with some obvious tag.
    ¯\_(ツ)_/¯

  • How do I remove spaces and special characters from the file name during rendering?

    I understand that I can set LR_renamingTokensOn to true, but I would like to replace all spaces in the file name with an underscore and remove characters not in the range A-Z and 0-9. What's the easiest way to achieve this?

    local photo = catalog:getTargetPhoto()
    local sesn = LrExportSession {
        photosToExport = { photo },
        exportSettings = {
            -- ... (determine from export preset) - whatev you want, just be sure you set export directory: LR_export_destinationPathPrefix
            LR_tokens = "{{custom_token}}",
            LR_tokenCustomString = LrPathUtils.removeExtension( photo:getFormattedMetadata( 'fileName' ) ):gsub( "[ %c]", "" ) -- remove spaces and control characters
    sesn:doExportOnNewTask()

  • How to use aggregator to create a single swf file from multiple files

    Hi everyone,
    I am working on the client's requirement where i have to create a SCROM 2004 based video. Its basically a PPT inside the captivate file. And it has around 175 slides in the file. Some of the slides have animations, voiceover. I am facing a problem during PUBLISHING the file into single SWF file format. Whenever I Publish the slides as SWF, it creates number of SWF files, Swf skin of the player and other manifest, Scorm 2004 files.
    I want only one single SWF file in which every slide should be incorporated in it. Dont know, why it is happening? I tried aggregator for this also, but it didnt worked... The Skin.swf has been easily added and no other files are adding. It shows me an error: "Name.swf is not a AS3 Captivate file ....."
    I am new to this. Please help me out as I have a very short deadline for this.
    Thanks and Regards

    Maybe you misunderstand: this is a user forum, not online help by Adobe staff.
    Sorry, but if you are that impatient, you'll have to pay for online support. You post a question and expect to have answers within minutes?
    Lilybiri

  • Using drag/drop to build data grid rows from multiple lists ?

    Hi,
    I have implemented some simple drag and drop between grids and lists, including images.
    What I need to do now is quite a bit more complex:
    Create rows in a data grid by dragging and dropping from multiple lists. That is, for a given
    row, column 1 receives data from list A and rows in column 2 - 5 receive data from List B
    I haven't found any examples that do this and my initial hacks haven't been successful.
    If you have any suggestions, they would be most appreciated !!!
    Thanks !  

    This does the trick...
    For my destination grid
    protected function dg_dragDropHandler(e:DragEvent):void
    // Dynamically add columns to the grid by dragging them from the new column list
                    if (e.dragInitiator["id"] == "lNewColumn")
                        e.preventDefault();    // handle this manually
                        var Id:Number;
                        var Name:String;
                        var numCols:int = e.dragInitiator["selectedItems"]["length"] as int;
                        for (var i:int=0; i < numCols; i++)
                            Id = e.dragInitiator["selectedItems"][i]["id"];
                            Name = e.dragInitiator["selectedItems"][i]["Name"];
                            addGridColumn(Id, Name);
    private function addGridColumn( Id:Number, Name:String ):void
                    var dgc:DataGridColumn;
                    var cols:Array = dg.columns;
                // not a duplicate column
                        dgc = new DataGridColumn(Name);
                        dgc.width=150;   
                        dgc.headerWordWrap = true;
                        dgc.itemRenderer=new ClassFactory(MyLovelyItemRenderer);    // unlike mxml, must explicitly cast
                        dgc.width=156;
                        dgc.headerText = Name + "\n Message";
                        dgc.dataField="messageId_" + Id.toString();    // allows split on '_' later to get Id
                        dgc.setStyle("textAlign","center");
                        cols.push(dgc);
                        dg.columns = cols;

  • Using applescript to open a folder with a keyboard shortcut

    hello -
    i have a rather simple question (probably). is there a way using applescript to create a keyboard command to open a folder? i.e. command shift a opens the applications folder and command shift u opens utilities. can i use applescript to designate a keyboard command to open a folder i have created? also, the script editor does not have to be open for me to utilize scripts, correct?
    thanks for your patience with a newbie.

    You can't make a keyboard shortcut to run a specific application from OSX, although there are third party applications such as Quicksilver that can do things like that. You can use an AppleScript to activate an existing menu item, for example:
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px;
    color: #000000;
    background-color: #FFDDFF;
    overflow: auto;"
    title="this text can be pasted into the Script Editor">
    tell application "Finder" to activate
    tell application "System Events" to tell application process "Finder"
    keystroke "A" using {shift down, command down}
    end tell</pre>
    Other alternatives to keyboard shortcuts are to use the Scripts Menu or add an application to the Finder's toolbar. The Script Editor does not need to be active to use scripts.

  • Prevent using special characters in file and folder names?

    I've recently begun adding windows clients to my network. In doing so, I've found that on my file shares from OS X server, the windows clients are unable to see files and folders which have names containing special characters such as / ? < > \ : * | ”
    Unfortunately my accounting department has been creating files with these characters in their names for several years. I would like to find if there is a way to prevent them from using a defined set of characters in the file and folder names to prevent them from "accidentally" doing so in the future.
    I've found that by turning off streams support on SMB in OS X server, that my windows clients can at least see that a file or folder should exist, albeit with a corrupted file name. Removing the special characters from these names allows the proper name to become visible and the file accessible.
    Any info would be greatly appreciated.

    (_seb_) wrote:
    > Gary White wrote:
    >> On Sun, 19 Nov 2006 19:15:04 +0100, "(_seb_)"
    <[email protected]> wrote:
    >>
    >>> "ça alors: it's a déjà-vu"
    >>>
    >>> How can I encode this so it's valid as a
    directory name, yet can be
    >>> displayed as intended when the name is output to
    the page.
    >>> urlencode() does not do the job, neither does
    htmlentities()...
    >>
    >>
    >> What's wrong with:
    >>
    >> $l="ça alors: it's a déjà-vu";
    >> print urlencode($l)."<br>\n";
    >> print htmlspecialchars($l);
    >>
    >> Gary
    >
    >
    > I know that, but what is the name of the directory? It
    has to be a real
    > directory name, not a string stored somewhere.
    >
    > What's a valid encoding for a directory named "ça
    alors: it's a
    > déjà-vu"? I can call a folder like this on my
    Mac, but it won't work on
    > any server...
    >
    >
    >
    PS: basically it's not a url encoding issue.
    I can url encode "ça alors: it's a déjà-vu",
    and pass it in a url query string. But my issue is not
    with an url query string, it's with an actual URL, that is,
    the actual name of the directory. It
    can't be "ça alors: it's a déjà-vu". But I
    want to allow the user to name their directory like that
    if they want. So I need a way to encode this into characters
    that can be used for an actual
    directory on the server.
    seb ( [email protected])
    http://webtrans1.com | high-end web
    design
    Downloads: Slide Show, Directory Browser, Mailing List

  • How can I call a specific search help from and still get all the tabs

    hello
    I use F4IF_FIELD_VALUE_REQUEST to display a specific search help from my program. This search help is included in a collective search help, but only the one specified search help is displayed.
    Is it possible to call the collective search help and display one specific search help ?
    Example: in CRM i have a collective search help BUPA. When F4 is issued from a customer field the search help "Search customer" should be displayed, and not the last search help which was activated - i.e.. "Search employee".
    best regards
    Peter Christiansen

    Hi,
    you can try some thing like this..
          CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST'
            EXPORTING
              TABNAME           = 'KNA1'
              FIELDNAME         = 'KUNNR'
              SEARCHHELP        = 'DEBI'
            TABLES
              RETURN_TAB        = LT_RETURN
            EXCEPTIONS
              FIELD_NOT_FOUND   = 1
              NO_HELP_FOR_FIELD = 2
              INCONSISTENT_HELP = 3
              NO_VALUES_FOUND   = 4
              OTHERS            = 5.
          IF SY-SUBRC <> 0.
            MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
    Regards
    vijay

Maybe you are looking for

  • Add File Name to Output

    Is it possbile to add the file name variable to topics after they are created without having to manually insert the variable? Upon inserting the variable, format is thus: <variable name=file x-format=default x-value=0001.htm>0001.htm</variable> The x

  • Oracle database 8.1.7.4

    hi friend, can any one give me link of oracle 8.1.7.4 database setup. so i can download it. thanks in advance

  • $$$$ License Exception when connecting to SQL Server for Weblogic 7.0

    Hi, I downloaded Weblogic 7.0, and installed and uninstalled a few times, When I tried to connect SQL Server 2000 using the samples in ..\examples\jdbc\mssqlserver4, I got the error: Exception was thrown: java.sql.SQLException: $$$$$$$$$$$$$$$$ Licen

  • Suggestion for new Mail feature

    It would be great to be able to file emails to folders by using a button on the toolbar, or a keyboard shortcut, that would open a text box in which you could type the name of the folder you want to file the email. (Also, it's too hard to find the li

  • Measuring data mess! Meas.doc gets created,but doesn't update plan!

    Hi colleagues, During testing I have encountered weird problem.. The measuring data, which I fill while TECO for work order stopped being consistent with measurement document list and maintenance plan counter reading in particular.. So, when i enter