Looking for, and replace special characters

Hi
I am quite new to AppleScript and can't figure this out. Any help would be appreciated.
I have received several (a lot of) folders containing images with some strange characters in the file names. The images has to go to web, and I want to replace those characters with some that are web friendly. The characters in question is some Swedish A's and O's (Ä, ä, Ö, ö) and one that looks like the Apple Command symbol. (I was told this one is a combination of a and e).
Then, I would like to replace all spaces between the words in the file names with an underscore.
In addition, all image file names start with capitals and I would like to replace these as well.
Thanks
Neal
G5   Mac OS X (10.4.6)  

Here's a modified version of the standard script:
try
tell application "Finder" to set the source_folder to (folder of the front window) as alias
on error -- no open folder windows
set the source_folder to path to desktop folder as alias
end try
display dialog "Search and replace in:" buttons {"File Names", "Folder Names", "Both"} default button 3
set the search_parameter to the button returned of the result
repeat
display dialog "Enter text to find in the item names:" default answer "" buttons {"Cancel", "OK"} default button 2
set the search_string to the text returned of the result
if the search_string is not "" then exit repeat
end repeat
repeat
display dialog "Enter replacement text:" default answer "" buttons {"Cancel", "OK"} default button 2
set the replacement_string to the text returned of the result
if the replacement_string contains ":" then
beep
display dialog "A file or folder name cannot contain a colon (:)." buttons {"Cancel", "OK"} default button 2
else if the replacement_string contains "/" then
beep
display dialog "A file or folder name cannot contain a forward slash (/)." buttons {"Cancel", "OK"} default button 2
else
exit repeat
end if
end repeat
display dialog "Replace “" & the search_string & "” with “" & the replacement_string & "” in every item name?" buttons {"Cancel", "OK"} default button 2
tell application "Finder"
set the item_list to every item of entire contents of source_folder
tell me
set item_list to reverse of the item_list
end tell
set source_folder to source_folder as string
repeat with i from 1 to number of items in the item_list
set the_name to name of item i of the item_list
set this_item to item i of the item_list
set this_info to properties of this_item
set the current_name to the_name
set change_flag to false
repeat with this_char from 1 to (count items of search_string)
if the current_name contains item this_char of (search_string) then
if the search_parameter is "Folder Names" and ¬
folder of this_info is true then
set the change_flag to true
else if the search_parameter is "File Names" and ¬
folder of this_info is false then
set the change_flag to true
else if the search_parameter is "Both" then
set the change_flag to true
end if
if the change_flag is true then
set this_item to item i of the item_list
-- replace target string using delimiters
set AppleScript's text item delimiters to the item this_char of search_string
set the textitemlist to every text item of the current_name
set AppleScript's text item delimiters to the item this_char of replacement_string
set the newitemname to the textitemlist as string
set AppleScript's text item delimiters to ""
set the current_name to newitemname
end if
end if
end repeat
my setitem_name(thisitem, current_name)
end repeat
end tell
beep 2
on setitem_name(thisitem, newitemname)
tell application "Finder"
--activate
set the parentcontainerpath to (get the container of this_item) as text
if not (exists item (the parentcontainerpath & newitemname)) then
try
set the name of this_item to newitemname
return this_item
on error the error_message number the error_number
if the error_number is -59 then
set the error_message to "This name contains improper characters, such as a colon (:)."
else --the suggested name is too long
set the error_message to error_message -- "The name is more than 31 characters long."
end if
--beep
tell me to display dialog the error_message default answer newitemname buttons {"Cancel", "Skip", "OK"} default button 3
copy the result as list to {newitemname, button_pressed}
if the button_pressed is "Skip" then return 0
my setitem_name(thisitem, newitemname)
end try
else --the name already exists
--beep
tell me to display dialog "This name is already taken, please rename." default answer newitemname buttons {"Cancel", "Skip", "OK"} default button 3
copy the result as list to {newitemname, button_pressed}
if the button_pressed is "Skip" then return 0
my setitem_name(thisitem, newitemname)
end if
end tell
end setitemname
This script variant works by accepting a source string in the form "AB" and desired string "CD". When run, ABCA will become CDCC with the sample strings.
(19254)

Similar Messages

  • Vbscript to rename files and replace special characters

    Dear Exprt,
    would you please help to add addtional requirement for rename and replace special characters for file
    by the below script i can re name.
    strAnswer = InputBox("Please enter folder location to rename files:", _
        "File rename")
        strfilenm = InputBox("Enter name:", _
        "Rename Files")
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Sub visitFolder(folderVar)
        For Each fileToRename In folderVar.Files
            fileToRename.Name = strfilenm & fileToRename.Name
        Next
        For Each folderToVisit In folderVar.SubFolders
            visitFolder(folderToVisit)
        Next
    End Sub
    If FSO.FolderExists(strAnswer) Then
        visitFolder(FSO.getFolder(strAnswer))
    End If
    [email protected]

    Thx would you please look below what wrong in its run  nothing happend no error
    strAnswer = InputBox("Please enter folder location to rename files:", _
        "Test")
        strfilenm = InputBox("Enter name:", _
        "Rename Files")
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set regEx = New RegExp
    'Your pattern here
    Select Case tmpChar
    Case "&"
    changeTo = " and "
    Case "/"
    changeTo = "_"
    Case Else
    changeTo = " "
    End Select
    regEx.Pattern = tmpChar 
    Sub visitFolder(folderVar)
        For Each fileToRename In folderVar.Files
            fileToRename.Name = strfilenm & fileToRename.Name 
            fileToRename.Name = regEx.Replace(fileToRename.Name, tmpChar)
        Next
        For Each folderToVisit In folderVar.SubFolders
            visitFolder(folderToVisit)
        Next
    End Sub
    [email protected]

  • Find and replacing special characters

    we have just discovered that after database unicode conversion, some special characters are starting to appear in the database after users copy and paste into the database.
    For example from a table, we can identify it with:
    SQL> select count(*) from table where column_name like '%' || chr(25) || '%';
    COUNT(*)
    15
    This is for a table.
    How can this be done to identify the characters for all tables because we are not sure of all the tables
    Thanks

    Hi,
    Please try below pl/sql block to identify special characters in tables with respect to columns
    set serveroutput on size 1000000
    declare
    procedure gooey(v_table varchar2, v_column varchar2) is
    type t_id is table of number;
    type t_dump is table of varchar2(20000);
    type t_data is table of varchar2(20000);
    l_id t_id;
    l_data t_data;
    l_dump t_dump;
    cursor a is
    select distinct column_name
    from dba_tab_columns
    where table_name = v_table
    and data_type = 'VARCHAR2'
    and column_name not in ('CUSTOMER_KEY','ADDRESS_KEY');
    begin
    for x in a loop
    l_id := null;
    l_data := null;
    l_dump := null;
    execute immediate 'SELECT ' || v_column || ', ' || x.column_name || ', ' ||
    'dump(' || x.column_name || ')'
    || ' FROM ' || v_table
    || ' WHERE RTRIM((LTRIM(REPLACE(TRANSLATE(' || x.column_name ||
    ',''ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@#$%^&*()_+
    -=,!\`~{}./?:";''''[ ]'',''A''), ''A'', '''')))) IS NOT NULL'
    bulk collect into l_id, l_data, l_dump;
    if l_id is not null then
    for k in 1..l_id.count loop
    dbms_output.put_line(v_table || ' - ' || x.column_name || ' - ' ||
    to_char(l_id(k),'999999999999'));
    dbms_output.put_line(l_data(k));
    dbms_output.put_line(l_dump(k));
    dbms_output.put_line('*********************');
    end loop;
    end if;
    end loop;
    end gooey;
    begin
    gooey('table1','coln1');
    gooey('table1','coln2');
    gooey('table2','coln3');
    end;
    Like this you can get special characters for all the columns/particular column from table
    Thanks,
    Nitin

  • Pages 5: Find and replace special characters

    Has this feature gone? Or can anyone tell me where to find it? I neeed, for example, to replace double paragraph breaks with single ones, how can I do this?

    I can't find it either, but the following appears to work:
    Turn on Show Invisibles in the View menu.
    Select (highlight) the double para breaks.
    Use Command-E  (Find using selected text).
    Open the Find dialogue box (Command-F) and select Find & Replace.The selected para breaks will be in the Find text entry box, but will not be visible!
    Click in the Replace text entry box.
    Select (highlight) a single para break.
    Go to the Edit menu / Find and select 'Use selection for replace' (it will not show in the Replace entry box).
    In the Find & Replace dialogue box, click on the Forward or Back arrows to highlight the selected items (e.g. double para break) where you wish to start replacing in the document.
    Use the Replace All / Replace & Find / Replace buttons as per usual.
    Not a nice solution, but I hope it gets you going until Apple restores the previous functionality!

  • I have set up my work Exchange email/calendar. After setting up I am getting passcode expired message and asking for changing the passcode with a 16   digit and 4 special characters. No combination of numberic, alphanumeric, special characters works. Help

    I have set up my work Exchange email/calendar. After setting up I am getting passcode expired message and asking for changing the passcode with a 16 +  digit and 4 special characters. No combination of numberic, alphanumeric, special characters is working. Help!!

    I have set up my work Exchange email/calendar. After setting up I am getting passcode expired message and asking for changing the passcode with a 16 +  digit and 4 special characters. No combination of numberic, alphanumeric, special characters is working. Help!!

  • 10g won't recognize ellipsis and other special characters.

    I'm trying to insert data into both VARCHAR2 and CLOB columns that contains characters such as ellipsis and other special characters. Oracle doesn't recognize the characters and just converts it to garbage. Is there a way to make Oracle easily recognize these characters?
    For example, it won't recognize the following ellipsis in the string:
    "Here we are … right now."

    My bad...I did look at the national character set instead.
    When I performed theq query you posted, I got the following:
    NLS_CHARACTERSET
    WE8MSWIN1252
    NLS_NCHAR_CHARACTERSET
    AL16UTF16
    I hope this new information helps. Also, the tool involved is SQL *Plus, but I'm currently concentrated on getting the insert to work via JDBC. Thanks in advance.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Replace special characters in FDF

    Hello,
    I have searched everywhere and cannot find the answer to this simple problem.  I can manipulate javascript in an HTML environment by using free scripts, but it's not so easy in a PDF form.  I am using Adobe Acrobat 9 Pro and I have a form that when filled out and submitted, generates and emails an FDF file.  I am using a server-side script called FormGenie to do this, and the script hates parentheses and some other special characters, they break the FDF file.  All I want to do is set up a document level Javascript that will check for and replace all instances of these special characters with something allowed like a hyphen- or just a space.
    I have tried:
    function clearText() {
         document.formname.fieldname.value=filterNum(document.formname.fieldname.value)
         function filterNum(str) {
              re = /\$|#|~|\%|\*|\^|\(|\)|\+|\=|\[|\]|\[|\}|\{|\;|\"|\<|\>|\?|\||\\|\!|\$/g;
              // remove special characters like "$" and "," etc...
              return str.replace(re, "-");
    and
    function clearText2(str) {
    stringName = stringName.replace(/\$|#|~|\%|\*|\^|\(|\)|\+|\=|\[|\]|\[|\}|\{|\;|\"|\<|\>|\?|\||\\|\!|\$ /g,'-');
    I know these aren't right, but I have to be at least barking up the right tree.
    Can someone help?
    Thank you

    OK, here is my first stab at putting together this  script from searching the API reference.
    To loop  through the text fields and get their values, I have:
    for  ( var i = 0; i < this.numFields; i++) {
    var fname = this.getNthFieldName(i);
    if ( fname.type = "text" ) f.value;   [Not sure if "f.value" is correct or legal here]
    If this is even getting close, where I get stuck  is how to get the original script to take those values and replace any unwanted characters found.
    if (!event.willCommit) {
        event.change = event.change.replace(/[\$\#\~\%\*\^\(\)\+\=\[\]\{\}\;\"\<\>\?\|\\\!]/g, "-");
    I just need to put this together correctly and I don't know how.
    I have the form submission part down, that was already done, I just need to add the custom "Run a javascript" item above it so that is executed first.
    Need a little guidance,
    Thanks

  • How to replace special characters in string.

    Hello,
    I want to replace special characters such as , or ; with any other character or " ".I find out there is no such function is java for this.There is only replace() but it accepts only chars.If anybody know how to do this?.
    Thanks,

    Hello,
    I want to replace special characters such as , or ;
    with any other character or " ".I find out there is no
    such function is java for this.There is only replace()
    but it accepts only chars.If anybody know how to do
    this?.
    Thanks,Can't you just do the following?
    public class Test
         public static void main(String[] args)
         String testString = "Hi, there?";
         System.out.println(testString.replace(',',' '));
    }

  • Im looking for a replacement of "Default Zoom Level" addon.

    Im looking for a replacement of "Default Zoom Level" addon. Why is this disabled in Firefox 5/6? Is there a similar addon or how can I set the default zoom?

    Did you do a compatibility check?
    That is required in cases where the extension has a maxVersion (in this case 4.0.*) set in the XPI file and the server has the correct compatibility data ([[https://versioncheck.addons.mozilla.org/update/VersionCheck.php?reqVersion=2&id={D9A7CBEC-DE1A-444f-A092-844461596C4D}&version=4.5&maxAppVersion=6.0&status=userEnabled&appID={ec8030f7-c20a-464f-9b0e-13a3a9e97384}&appVersion=5.0&appOS=Windows&appABI=x86-msvc&locale=en-US&currentAppVersion=5.0&updateType=97 8.*]]).
    From https://addons.mozilla.org/en-US/firefox/addon/default-fullzoom-level/<br />
    Works with: Firefox 3.6 - 8.*

  • Looking for a replacement smartphone for my Treo 755s

    Earlier this year, I bought a refurbished Treo 755s, the ebay seller it was new. I bought the Treo 755s to replace my dying Tungsten E2 and thought it would be nice to have my Palm and cell phone together. I have not been happy with this Treo 755s. The past few months, every time I hotsync, it needs to reset. I can not beam wit it. The camera is terrible. 
    I'm looking for a replacement smartphone. I want something with the nice features of Palm (calendar, contacts, memos, tasks & photo album), a good camera and easy to use phone. I also do not have Windows Outlook. I have Verizon cell phone service.
    Post relates to: Treo 755p (Verizon)

    Hi CKLB,
    Welcome to the forum.
    These guys appear to specialise in International keyboards. Worth a call to see if they have the Russian flavour:
    http://www.welovemacs.com/apmake.html
    Alternatively, these guys sell Russian keyboard stickers which may be of interest:
    http://www.latkey.com/keyboard_stickers.asp?SubCat=6
    RD

  • Find and Replace Japanese characters in pdf file on iPhone

    Hi eveybody !
    I want to find and replace Japanese characters in pdf on iPhone.
    I using zlib to deflate stream - endstream block and extract text.It's work fine with latin-text.
    But when i work with japanese characters , I don't know how to do it ?
    I decode a sample japanese pdf file, and I know that each Japanese characters are performances as hex string : "<01b7><0e230a23>..."
    But i don't know how to convert Japanese characters to the hex string like that.
    Can evrybody help me?
    Thanks!

    Searching is the same process as extracting - since it's about turning page content into something understandable.  So that still remains what you need to learn/understand - of course, referring back to all the previous sections about font formats, etc.
    Replacing in PDF is EXTREMELY DIFFICULT for two reasons - subset fonts and explicit glyph positioning.  Have you determine (conceptually, if nothing else) how you plan to addresses these two issues?
    PDF doesn't do UTF8 for page content - so don't worry about that.

  • Capturing returns and other special characters

    Greetings,
    I'm curious to know what is 'normally' done to capture
    returns and other special characters from textareas. I want my user
    to be able to insert 'control' characters into the text area to
    allow them to provide some structure to the information they're
    entering. At the moment, I'm processing the text char by char and
    working out if it's an 'enter' or whatever, then appending a
    '<br />' to the string before I store it and so on.
    Is there a more established way to do this sort of
    thing?

    Use the replace function to replace either chr(10) or chr(13)
    with a break tag. It's using cold fusion functions to accomplish
    the same thing you appear to be doing manually.

  • E72: Swedish and other special characters not work...

    When I send mail through MfE, swedish and other special characters do not reach the recipient, they are just ignored. No blanks or nothing. Every word with a swedish character ends up one letter short.
    Before the firmware upgrade this was intermittent, happening only on about half of my mails.
    Now I upgraded yesterday, and it seems the problem is now permanent.
    Have seen similar posts from E75 and E90 owners, their problems seem to have been fixed by newer firmware.
    Our setup is: Exchange 2003, Portwise authentication.
    All other phone models work fine, like iPhone, E71 etc.
    /Sebastian

    After some testing I found out that if I use swedish chars in the subject line, it works fine. Even in the mail body.
    If I don't use swedish chars in the subject, they won't work in the body. I either get garbage or nothing where the swedish chars should be.
    The problem doesn't exist at all in my private IMAP mail account.
    Could someone who uses Mail for Exchange and have special chars in their alphabet (swedish, finnish, german, hungarian etc) pls tell me how it's working out for you?
    Message Edited by Seb_Martin on 28-Jan-2010 11:15 AM

  • SCOM - -500 Internal Server Error - There is a problem with the resource you are looking for, and it cannot be displayed

    Hi There,
    Need your assistance on the issue that we are facing in prod environment.
    We are able to open web console from remote machine and able to view monitoring pane as well as my workplace folders from console . Able to view and access alerts and other folder in the monitoring pane. We are able to view and access My Workplace folder
    and able to view the reports in Favorite Reports folder. But when I click on run Report we  are getting the below error  "500 Internal Server Error - There is a problem with the resource you are looking for, and it cannot be displayed."
    In our environment we have 3 servers one is SQL server and two are SCOM servers. Please advise how to fix this issue. Do we have to do any thing from SQL End?
    Errors: Event ID 21029: Performance data from the OpsMgr connector could not be collected since opening the shared data failed with error "5L".
     Event ID 6002 : Performance data from the Health Service could not be collected since opening the shared data failed with error 5L (Access is denied.).
    Regards,
    Sanjeev Kumar

    Duplicate thread:
    http://social.technet.microsoft.com/Forums/en-US/7675113e-49f0-4b3a-932b-4aceb3cfa981/scom-500-internal-server-error-there-is-a-problem-with-the-resource-you-are-looking-for-and-it?forum=operationsmanagerreporting
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Is there a program or setting that looks for and installs software updates?

    Is there a program or setting that looks for and installs software updates?

    System Preferences > Apps Store
    Enable all those options.

Maybe you are looking for

  • Error loading csv file from application server

    Hi all, While uploading a csv file from the application server to psa we are getting the following error, Error 2 while splitting CSV data record Message no. RSDS_ACCESS011 Diagnosis Error 2 occurred while splitting the CSV data record 1 1 = Could no

  • How do i log out of imessage on my macbook pro?

    how do i log out of imessage on my macbook pro

  • HT4814 Is it possible to manage the mac mini server with server app before set up?

    The article says using the server app I need to enter the IP address, then the Administrator name and password, but obviously on the first boot these are not configured yet. The article does not mention if this is possible or the server.app can only

  • Changing list of top participants?

    I was in the Reader forum and needed to take a look at a recent post. For this , I had to go to the second page of the list. In both, the lis t of Top Participants looked its normal: I opnened the wrong message on page 2, and tried to go back to the

  • MIGO Goods issue ref. to order error in SAP

    Hi, I have created a service order with IW34 or IW51, in that servie order i have use 5 items. When i am issuing material using MB1A Ref. to order all the items in that order are coming properly and i am able to post them but same when i try to issue