Copy link to clipboard
Copied
In my document object still text frames, I want to export as snippets
but in the present specification in the paragraph style, but also get the name of the snippet
I have written a code for it, but the results frustrated
var myDoc = app.activeDocument;
for(var p=0; p<myDoc.pages.length; p++)
{
for(var i =0;i<myDoc.pages
.textFrames.length;i++)
{
var myFrame = myDoc.pages
.textFrames;
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = ".+";
app.findGrepPreferences.appliedParagraphStyle = myParS;
var mySearch = myFrame.findGrep();
for(j=0; j<mySearch.length; j++)
{
if(myFrame.appliedObjectStyle == tmc) {
myFrame.exportFile(ExportFormat.INDESIGN_SNIPPET, File("d:\\Yeni\\"+ mySearch
+ ".idms")); }
}
}
}
Hope this help you
...var myDoc = app.activeDocument;
var myItems= myDoc.allPageItems;
var J = myItems.length;
while( J-- ){
var mItem = myItems
; if (mItem.constructor instanceof TextFrame) {
if(mItem.appliedObjectStyle.name =="tmc"){
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = "\\d{4}";
app.findGrepPreferences.appliedParagraphStyle = "myParS";
var mySearch = mItem.fi
Copy link to clipboard
Copied
Hi,
I don't really understand what you want to do. Could you specify ?
Regards
Copy link to clipboard
Copied
"tmc" has named object style
This style has a paragraph style applied to text frame in (myPars)
I want to make snippets s TMC
but snippet is name myPars text value

Copy link to clipboard
Copied
I'm not sure that's what you want to do ...
var myDoc = app.activeDocument;
for(var p=0; p<myDoc.pages.length; p++){
for(var i =0;i<myDoc.pages
.textFrames.length;i++){
var myFrame = myDoc.pages
.textFrames;
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = ".+";
app.findGrepPreferences.appliedParagraphStyle = 'foo';
var mySearch = myFrame.findGrep();
for(j=0; j<mySearch.length; j++){
if(myFrame.appliedObjectStyle.name == 'tmc') {
myFrame.exportFile(ExportFormat.INDESIGN_SNIPPET, File("~/Desktop/"+ 'tmc' + ".idms"));
}
}
}
}
Copy link to clipboard
Copied
How can I explain more

Copy link to clipboard
Copied
Try this
for(var p=0; p<myDoc.pages.length; p++){
for(var i =0;i<myDoc.pages
.textFrames.length;i++){
var myFrame = myDoc.pages
.textFrames;
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = ".+";
app.findGrepPreferences.appliedParagraphStyle = 'myPars';
var mySearch = myFrame.findGrep();
for(j=0; j<mySearch.length; j++){
if(myFrame.appliedObjectStyle.name == 'tmc') {
myFrame.exportFile(ExportFormat.INDESIGN_SNIPPET, File("~/Desktop/"+ mySearch
.contents + ".idms")); }
}
}
}
Copy link to clipboard
Copied
thanks
if the group I can not name in
How to make a snippet
var myDoc = app.activeDocument;
var myGrup = myDoc.groups.everyItem();
var myGframe = myGrup.textFrames[0];
if(myGframe.appliedObjectStyle =="tmc"){
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = "\\d{4}";
app.findGrepPreferences.appliedParagraphStyle = "myParS";
var mySearch = myGframe.findGrep();
myGrup.exportFile(ExportFormat.INDESIGN_SNIPPET, File("D:\\Yeni\\"+ mySearch.contents + ".idms"));
}
Copy link to clipboard
Copied
Hope this help you
var myDoc = app.activeDocument;
var myItems= myDoc.allPageItems;
var J = myItems.length;
while( J-- ){
var mItem = myItems
; if (mItem.constructor instanceof TextFrame) {
if(mItem.appliedObjectStyle.name =="tmc"){
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = "\\d{4}";
app.findGrepPreferences.appliedParagraphStyle = "myParS";
var mySearch = mItem.findGrep();
if (mySearch.length ==1){
if (mItem.parent instanceof Group){
mItem.parent.exportFile(ExportFormat.INDESIGN_SNIPPET, File("~/Desktop/"+ mySearch[0].contents + ".idms"));
}else{
mItem.exportFile(ExportFormat.INDESIGN_SNIPPET, File("~/Desktop/"+ mySearch[0].contents + ".idms"));
}
}
}
}
}
Copy link to clipboard
Copied
For this code in paragraph style
for example
19 FIZ E 3854 (.appliedParagraphStyle = "myParS")
How can we get only 4-digit numbers
.replace(/(\d+)(\t.+?\t)(.+?\t)(\d+)/g, '$4');
where I could not find how to write
Copy link to clipboard
Copied
The above code also works in this case ...
- app.findGrepPreferences.findWhat = "\\d{4}";
- app.findGrepPreferences.appliedParagraphStyle = "myParS";
Copy link to clipboard
Copied
yes but my list which can be
12 FIZ A 651531
13 FIZ B 12358743
14 FIZ E 84435
I will take them through how
651531
12358743
84435
Copy link to clipboard
Copied
Try with this ...
var myDoc = app.activeDocument;
var myItems= myDoc.allPageItems;
var J = myItems.length;
while( J-- ){
var mItem = myItems
; if (mItem.constructor instanceof TextFrame) {
if(mItem.appliedObjectStyle.name =="tmc"){
app.findGrepPreferences = app.changeGrepPreferences = null;
//app.findGrepPreferences.findWhat = "\\d{4}";
app.findGrepPreferences.findWhat = "\\d+$";
app.findGrepPreferences.appliedParagraphStyle = "myParS";
var mySearch = mItem.findGrep();
if (mySearch.length ==1){
if (mItem.parent instanceof Group){
mItem.parent.exportFile(ExportFormat.INDESIGN_SNIPPET, File("~/Desktop/"+ mySearch[0].contents + ".idms"));
}else{
mItem.exportFile(ExportFormat.INDESIGN_SNIPPET, File("~/Desktop/"+ mySearch[0].contents + ".idms"));
}
}
}
}
}
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more