Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #5746

    Yutaka Emura
    Keymaster

    // Replace in Files - multiple times (JavaScript)
    editor.ReplaceInFiles( "replace what (1)", "replace with (2), "c:test*.txt", eeReplaceBackup, eeEncodingSystemDefault, "", "c:backup" );
    editor.ReplaceInFiles( "replace what (2)", "replace with (2), "c:test*.txt", eeReplaceBackup, eeEncodingSystemDefault, "", "c:backup" );
    editor.ReplaceInFiles( "replace what (3)", "replace with (3), "c:test*.txt", eeReplaceBackup, eeEncodingSystemDefault, "", "c:backup" );
    ...
    #19927

    Simon McMahon
    Participant

    Hi there, I have a problem with my existing Macro not working for replace in files across 80+ XML files. Here is a sample of the current macro which fails to run.

    editor.ReplaceInFiles( “<“,”<“, “*.xml”, eeReplaceBackup, eeEncodingSystemDefault, “*.bak”, “C:\\xmlBackup” );
    editor.ReplaceInFiles( “>”,”>”, “*.xml”, eeReplaceBackup, eeEncodingSystemDefault, “*.bak”, “C:\\xmlBackup” );
    editor.ReplaceInFiles( “&”,”&”, “*.xml”, eeReplaceBackup, eeEncodingSystemDefault, “*.bak”, “C:\\xmlBackup” );
    editor.ReplaceInFiles( “"”,”\x22″, “*.xml”, eeReplaceBackup, eeEncodingSystemDefault, “*.bak”, “C:\\xmlBackup” );
    editor.ReplaceInFiles( “'”,”\x27″, “*.xml”, eeReplaceBackup, eeEncodingSystemDefault, “*.bak”, “C:\\xmlBackup” );
    editor.ReplaceInFiles( “–”,”-“, “*.xml”, eeReplaceBackup, eeEncodingSystemDefault, “*.bak”, “C:\\xmlBackup” );
    editor.ReplaceInFiles( “&”,”and”, “*.xml”, eeReplaceBackup, eeEncodingSystemDefault, “*.bak”, “C:\\xmlBackup” );
    editor.ReplaceInFiles( “ ”,” “, “*.xml”, eeReplaceBackup, eeEncodingSystemDefault, “*.bak”, “C:\\xmlBackup” );
    editor.ReplaceInFiles( “&”,”and”, “*.xml”, eeReplaceBackup, eeEncodingSystemDefault, “*.bak”, “C:\\xmlBackup” );
    editor.ReplaceInFiles( “<![CDATA[“,””, “*.xml”, eeReplaceBackup, eeEncodingSystemDefault, “*.bak”, “C:\\xmlBackup” );
    editor.ReplaceInFiles( “]]>”,””, “*.xml”, eeReplaceBackup, eeEncodingSystemDefault, “*.bak”, “C:\\xmlBackup” );
    editor.ReplaceInFiles( “<category></category>”,”<category>Event XML Upload</category>”, “*.xml”, eeReplaceBackup, eeEncodingSystemDefault, “*.bak”, “C:\\xmlBackup” );
    editor.ReplaceInFiles( “]]>”,””, “*.xml”, eeReplaceBackup, eeEncodingSystemDefault, “*.bak”, “C:\\xmlBackup” );
    editor.ReplaceInFiles( “&”,”and”, “*.xml”, eeReplaceBackup, eeEncodingSystemDefault, “*.bak”, “C:\\xmlBackup” );
    editor.ReplaceInFiles( “#8216;”,”‘”, “*.xml”, eeReplaceBackup, eeEncodingSystemDefault, “*.bak”, “C:\\xmlBackup” );
    editor.ReplaceInFiles( “#8217;”,”‘”, “*.xml”, eeReplaceBackup, eeEncodingSystemDefault, “*.bak”, “C:\\xmlBackup” );
    editor.ReplaceInFiles( “#8230;”,”…”, “*.xml”, eeReplaceBackup, eeEncodingSystemDefault, “*.bak”, “C:\\xmlBackup” );
    editor.ReplaceInFiles( “#8220;”,”‘”, “*.xml”, eeReplaceBackup, eeEncodingSystemDefault, “*.bak”, “C:\\xmlBackup” );
    editor.ReplaceInFiles( “#8221;”,”‘”, “*.xml”, eeReplaceBackup, eeEncodingSystemDefault, “*.bak”, “C:\\xmlBackup” );
    editor.ReplaceInFiles( “#8212;”,”-“, “*.xml”, eeReplaceBackup, eeEncodingSystemDefault, “*.bak”, “C:\\xmlBackup” );
    editor.ReplaceInFiles( “#39;”,”‘”, “*.xml”, eeReplaceBackup, eeEncodingSystemDefault, “*.bak”, “C:\\xmlBackup” );
    editor.ReplaceInFiles( “and'”,”‘”, “*.xml”, eeReplaceBackup, eeEncodingSystemDefault, “*.bak”, “C:\\xmlBackup” );
    editor.ReplaceInFiles( “<p>andnbsp;</p>”,””, “*.xml”, eeReplaceBackup, eeEncodingSystemDefault, “*.bak”, “C:\\xmlBackup” );
    editor.ReplaceInFiles( “<organisation><p>”,”<organisation>”, “*.xml”, eeReplaceBackup, eeEncodingSystemDefault, “*.bak”, “C:\\xmlBackup” );
    editor.ReplaceInFiles( “</p></organisation>”,”</organisation>”, “*.xml”, eeReplaceBackup, eeEncodingSystemDefault, “*.bak”, “C:\\xmlBackup” );

    Can you suggest correct syntax so it will run on version 14.9.3

    #19929

    Yutaka Emura
    Keymaster

    Hello Simon,

    This forum can change double quotes to curly quotes, and some other changes. Would you please zip a sample JavaScript file and send it to tech@emurasoft.com ?
    Also, all these lines have the same issue? If so, please simplify the macro to only one or a few line(s) to make it easier to test.

    I have a problem with my existing Macro not working for replace in files across 80+ XML files

    Can you explain more details of the problem?

    Thank you,

    #19931

    Simon McMahon
    Participant

    Hi I have emailed the files as requested.
    xmlFilesForChange.zip
    fix-special-characters-in-files(original2).zip

    #19932

    Yutaka Emura
    Keymaster

    Hello Simon,

    Thank you for sending me files.

    The third parameter of the ReplaceInFiles method should be a fully-qualified path. You should replace “*.xml” with “C:\\… xmlFilesForChange …\\*.xml”. After this change, the macro works well.

    Thanks,

    #19933

    Simon McMahon
    Participant

    Thanks Yutaka, that has worked. My string is now by way of example:
    editor.ReplaceInFiles( “<“,”<“, “C:\\temp\\*.xml”, eeReplaceBackup, eeEncodingSystemDefault, “*.bak”, “C:\\xmlBackup” );
    editor.ReplaceInFiles( “>”,”>”, “C:\\temp\\*.xml”, eeReplaceBackup, eeEncodingSystemDefault, “*.bak”, “C:\\xmlBackup” );
    editor.ReplaceInFiles( “&”,”&”, “C:\\temp\\*.xml”, eeReplaceBackup, eeEncodingSystemDefault, “*.bak”, “C:\\xmlBackup” );

    #20689

    Simon McMahon
    Participant

    Hi Yataka, I have another replace in files problem. I tried to record a macro to do the following

    Replace this line:
    <xsl:output method=”html” encoding=”UTF-8″ indent=”yes” doctype-public=”-//W3C//DTD XHTML 1.0 Transitional//EN” doctype-system=”http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”/>

    With this line:
    <xsl:output method=”xml” encoding=”UTF-8″ indent=”yes” />

    In over 100 .XSL files.

    I thought given the ” quotes in the strings I would need to use a double quote to refer to each string, but this has failed.

    Can you suggest the correct macro? My not working example is below. I can send you some sample .XSL files if you need them to test,

    Thanks, Simon

    // Replace in Files – XML header line (JavaScript)
    editor.ReplaceInFiles( “”<xsl:output method=”html” encoding=”UTF-8″ indent=”yes” doctype-public=”-//W3C//DTD XHTML 1.0 Transitional//EN” doctype-system=”http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”/>””,””<xsl:output method=”xml” encoding=”UTF-8″ indent=”yes” />””, “C:\\temp\\*.xsl”, eeReplaceBackup, eeEncodingSystemDefault, “*.bak”, “C:\\xmlBackup” );

    #20690

    Yutaka Emura
    Keymaster

    Hello,

    I think you should use eeEncodingUTF8 for the nFlags parameter. You can email me both your sample file and not working macro (after zipped) at tech at emurasoft.com.

    Thanks,

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.