jEdit Community - Resources for users of the jEdit Text Editor
How can I run a macro over all files in a specific directory ?
Submitted by xcablex on Tuesday, 25 October, 2011 - 10:04
Hi,

I am totaly new in the usage of jEdit. I just finished a small macro for a "find&replace" purpose in about a hundred txt files.

Is there a way to tell jEdit to run the macro on all files in a specific directory ?

-- Peter
Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.
yes
by Robert Schwenn on Tue, 25/10/2011 - 17:44
Hi,
I just recorded a macro while doing a directory search manually, which should do the job.:

SearchAndReplace.setSearchString("xxxxxxxxxxx");
SearchAndReplace.setAutoWrapAround(false);
SearchAndReplace.setReverseSearch(false);
SearchAndReplace.setIgnoreCase(true);
SearchAndReplace.setRegexp(false);
SearchAndReplace.setSearchFileSet(new DirectoryListSet("X:\\Your\\Path\\here\\","*.txt",true));
SearchAndReplace.hyperSearch(view,false);

Robert
 
...
by xcablex on Tue, 25/10/2011 - 21:35
Thanks!
Can't test it right now. Will try it tomorrow. But how I have to handle it ? Do I have insert it in my own macro ?
 
yes
by Robert Schwenn on Wed, 26/10/2011 - 17:49
Yes Smiling
 
Doesn't work
by xcablex on Thu, 27/10/2011 - 09:12
Hey, after running the macro a window named HyperSearch Results opens, saying -No results found for "[]+"- this is my actual macro:
    SearchAndReplace.setSearchString("xxxxxxxxxxx"); SearchAndReplace.setAutoWrapAround(false); SearchAndReplace.setReverseSearch(false); SearchAndReplace.setIgnoreCase(true); SearchAndReplace.setRegexp(false); SearchAndReplace.setSearchFileSet(new DirectoryListSet("/home/xcablex/Desktop/test/","*.txt",true)); SearchAndReplace.hyperSearch(view,false); SearchAndReplace.setSearchString("- "); SearchAndReplace.setReplaceString("-"); SearchAndReplace.setBeanShellReplace(false); SearchAndReplace.setIgnoreCase(false); SearchAndReplace.setRegexp(true); SearchAndReplace.setSearchFileSet(new CurrentBufferSet()); SearchAndReplace.replaceAll(view); SearchAndReplace.setSearchString(" F([^e])"); SearchAndReplace.setReplaceString("F$1"); SearchAndReplace.setBeanShellReplace(false); SearchAndReplace.setIgnoreCase(false); SearchAndReplace.setRegexp(true); SearchAndReplace.setSearchFileSet(new CurrentBufferSet()); SearchAndReplace.replaceAll(view); SearchAndReplace.setSearchString("(\\w) \\["); SearchAndReplace.setReplaceString("$1["); SearchAndReplace.setBeanShellReplace(false); SearchAndReplace.setIgnoreCase(false); SearchAndReplace.setRegexp(true); SearchAndReplace.setSearchFileSet(new CurrentBufferSet()); SearchAndReplace.replaceAll(view); SearchAndReplace.setSearchString("^[ ]+"); SearchAndReplace.setReplaceString(""); SearchAndReplace.setBeanShellReplace(false); SearchAndReplace.setIgnoreCase(false); SearchAndReplace.setRegexp(true); SearchAndReplace.setSearchFileSet(new CurrentBufferSet()); SearchAndReplace.replaceAll(view); SearchAndReplace.setSearchString("[ ]+"); SearchAndReplace.setReplaceString(";"); SearchAndReplace.setBeanShellReplace(false); SearchAndReplace.setIgnoreCase(false); SearchAndReplace.setRegexp(true); SearchAndReplace.setSearchFileSet(new CurrentBufferSet()); SearchAndReplace.replaceAll(view);
Where can I find references what I am exactly doing in this macro ?
 
I start getting it
by xcablex on Thu, 27/10/2011 - 09:27
Didn't saw the "Directory" and "Subdirectory" Options in the Search & Replace Dialoge.
User login
Browse archives
« November 2024  
MoTuWeThFrSaSu
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
Poll
Are you interested in language packs for jEdit?
Yes, and I could help maintain translations
26%
Yes, I'd like to have translations
32%
Indifferent
35%
No, that'd be bad (please comment)
7%
Total votes: 1093
Syndication
file   ver   dls
German Localization light   4.4.2.1   101634
Context Free Art (*.cfdg)   0.31   46062
BBEdit scheme   1.0   18601
JBuilder scheme   .001   18502
ColdFusion scheme   1.0   18031
R Edit Mode - extensive version   0.1   17481
Advanced HTML edit mode   1.0   16213
Matlab Edit Mode   1.0   16075
jEdit XP icons   1.0   15236
XP icons for jEdit   1.1   14300