Copy link to clipboard
Copied
Hello all.
Is there any way to change script line:
app.loadFindChangeQuery ("QUERYNAME", SearchModes.grepSearch);app.activeDocument.changeGrep();
to load this query from another directory than default for Indesign?
Copy link to clipboard
Copied
Probably not, but you can use a startup script to copy the xml files from a shared directory to the Adobe saved queries folder.
If you decide to go this route, I suggest that your shared directory include a folder for obsolete queries. The startup script can then read the names of the files there and remove them from the Adobe folder. Otherwise, the trash piles up in the user's collection. I can post an example if you want it.
I actually prefer this approach to the venerable FindChangeByList script. This forum has many threads started by people who have a working find-change query but run into trouble trying to translate it into plain text for the list. Distributing the xml eliminates that step.
Bob
Copy link to clipboard
Copied
Hi @Robert Kyle, I'm interested in your approach and to see your example. Sounds clever.
- Mark
Copy link to clipboard
Copied
So the first step is to define serverQueriesFolder as a shared folder, available to all users, where you'll copy the .xml files that you want to share. Then
var userQueriesFolder = Folder(Folder.userData + "/Adobe/InDesign/Version 8.0/en_US/Find-Change Queries/GREP/");
varr fileList =serverQueriesFolder.getFiles("*.xml");
if (fileList.length === 0) { exit()};
for (q = 0; q < fileList.length; q++) {
var r = fileList[q].copy(userQueriesFolder + "/" + fileList[q].name);
}
If you modify one of your saved queries, just save a new .xml file to the shared folder. But the shared folder also should contain a subfolder called Obsolete. If/when you need to remove a saved query, just drag it to the subfolder.
The javascript code then needs to define the variable obsQueriesFolder and use it like this:
var obsList =obsQueriesFolder.getFiles("*.xml");
if (obsList.length > 0) {
var f = 0;
for (var i = 0; i < obsList.length; i++) {
var qFile = File (userQueriesFolder + "/" + obsList[i].name);
if (qFile.exists) {
qFile.remove();
f++
}
}
}
The javascript files goes into the Adobe startup scripts folder so that each user runs it when they launch Indesign. The saved queries will then be available to all users and can be run from the InDesign interface or called by other scripts using the loadFindChangeQuery() method.
I've only used it to share Grep queries but it's a good bet that it could be modified to handle other queries. Just add more subfolders to the shared directory and add more loops to the script.
Bob
Copy link to clipboard
Copied
Hi,
When i try your solution and copy files into "Find-Change Queries" directory, i have an error "Permission denied".
Don't you have any problems on your side ?
Thanks.
Cyril
Copy link to clipboard
Copied
No. Sounds like a permissions issue. Can you manually copy a saved query into your userData folder?
Copy link to clipboard
Copied
I forgot to say that i'm working with InDesign Server.
So queries are saved into C:\Program Files\Adobe\Adobe InDesign Server 2022\Presets\Find-Change Queries.
Copy link to clipboard
Copied
yes i can copy manually into userData directory but in my case, it's not in that folder. I think i don't have sufficient right to copy into indesign server install directory.
Copy link to clipboard
Copied
Hi @Łukasz24983335wax1 ,
to answer your question: "…to load this query from another directory than default for Indesign?"
Basically, yes. With a workaround.
The idiotic thing is that app.loadFindChangeQuery() only takes the name of a query as the first argument and not a file object. It's the name without the suffix *.xml. And of course the query must be stored in the default directory for queries of your user folder.
A possible workaround:
You could have stored a query *.xml file somewhere on your harddisk where you have read/write access. First check if a file with the same name exists in the appropriate subfolder of your user folder where the queries are stored. If the file already exists, remove it and copy over the new *.xml file. If it does not exist there, just copy over the xml file. Then load it with app.loadFindChangeQuery().
Tested that workflow with a GREP query file.
A perhaps cosmetical issue with this:
The pattern of the GREP query is visible in the GUI of the GREP Find tab, but the loaded query's name is not.
The folder of your stored GREP query files ( Desktop InDesign, not InDesign Server ) should be available with:
var findChangeQueriesFolderGREP =
Folder( app.scriptPreferences.scriptsFolder.parent.parent +"/"+ "Find-Change Queries" +"/"+ "GREP" );
This is independent from the localized version of InDesign and should work from InDesign CS6 to InDesign 2022.
Regards,
Uwe Laubender
( Adobe Community Professional )
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more