- AuthorPosts
- May 5, 2008 at 5:34 pm #5746Yutaka EmuraKeymaster
// 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" );
...
March 16, 2015 at 8:42 pm #19927Simon McMahonParticipantHi 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
March 18, 2015 at 8:11 pm #19929Yutaka EmuraKeymasterHello 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 [email protected] ?
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,
March 18, 2015 at 11:09 pm #19931Simon McMahonParticipantHi I have emailed the files as requested.
xmlFilesForChange.zip
fix-special-characters-in-files(original2).zipMarch 19, 2015 at 10:29 am #19932Yutaka EmuraKeymasterHello 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,
March 20, 2015 at 2:23 am #19933Simon McMahonParticipantThanks 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” );April 7, 2016 at 6:54 pm #20689Simon McMahonParticipantHi 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” );April 7, 2016 at 7:25 pm #20690Yutaka EmuraKeymasterHello,
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,
- AuthorPosts
- You must be logged in to reply to this topic.