When I open a cocosbuilder project again after I adding some new directories, it pops up a dialog that says
Too Many Directories
You have created or opened a project which is in a directory with very many sub directories. Please save your project-files in a directory together with the resources you use in your project.
I know it is because there are too many directories.
But I wonder if there is any other method that can solves this problem except removing my new added directories.
Thanks.
You could always remove the warning directly in CocosBuilder source and rebuilt it, provided that you use the github version.
Otherwise you could petition for the change requested by MK on github.
The offending code is located in CocosBuilderAppDelegate.m, around line ~1155
[[CocosBuilderAppDelegate appDelegate] modalDialogTitle:#"Too Many [...]
You will have to remove this line in at least two places.
- (void) checkForTooManyDirectoriesInCurrentDoc
{
if (!currentDocument) return;
if ([ResourceManager sharedManager].tooManyDirectoriesAdded)
{
// Close document if it has too many sub directories
NSTabViewItem* item = [self tabViewItemFromDoc:currentDocument];
[tabView removeTabViewItem:item];
[ResourceManager sharedManager].tooManyDirectoriesAdded = NO;
// Notify the user
[[CocosBuilderAppDelegate appDelegate] modalDialogTitle:#"Too Many Directories" message:#"You have created or opened a file which is in a directory with very many sub directories. Please save your ccb-files in a directory together with the resources you use in your project."];
}
}
- (BOOL) checkForTooManyDirectoriesInCurrentProject
{
if (!projectSettings) return NO;
if ([ResourceManager sharedManager].tooManyDirectoriesAdded)
{
[self closeProject];
[ResourceManager sharedManager].tooManyDirectoriesAdded = NO;
// Notify the user
[[CocosBuilderAppDelegate appDelegate] modalDialogTitle:#"Too Many Directories" message:#"You have created or opened a project which is in a directory with very many sub directories. Please save your project-files in a directory together with the resources you use in your project."];
return NO;
}
return YES;
}
Update:
In CocosBuilder/ccBuilder/ResourceManager.h
There is a marco defined as below:
#define kCCBMaxTrackedDirectories 50
So we can simply change 50 to a larger number, and the problem can be solved.
Related
So I made a script for Photoshop based on this generator
The important part is
#target photoshop
function main() {
// prompt user to select source file, cancel returns null
var sourceFile = File.openDialog("Select a 1:1 sqaure PNG file that is at least 618x618.", "*.png", false);
if (sourceFile == null) {
// user canceled
return;
}
var doc = open(sourceFile, OpenDocumentType.PNG);
if (doc == null) {
alert("Oh shit!\nSomething is wrong with the file. Make sure it is a valid PNG file.");
return;
}
....
}
main();
this allways worked. But when today I wanted to change something in the script (I haven't even started yet and not used it for about 2 weeks) I suddendly only get an error (translated from german):
Error 8000: The file can not be opened since the parameters for opening are incorrect.
Line:764
-> doc = open(sourceFile, OpenDocumentType.PNG);
How can I open a PNG file via a File.Open dialog in a Photoshop script?
I already tried to add the app
var doc = app.open(sourceFile, OpenDocumentType.PNG);
to remove the document type specifier
var doc = open(sourceFile);
or to add this as I saw it in many forums
var doc = open(sourceFile, OpenDocumentType.PNG, undefined);
and variations between them. Nothing helped so far.
For debugging I also added
alert(sourceFile);
before the according line and get e.g.
~/Desktop/Example/originalImage_2000x2000.png
The problem apparently was with Photshop in general!
When I opened Photshop I didn't even get the default view of last opened files etc and actually was not able to open any file ... but never tested this first.
After rebooting the PC and launching Photshop now everything went back to normal and the script just runs fine and as expected.
I have recently discovered macros and how they can surprisingly ease my life working on Fiji/ImageJ.
I created this macro:
run("Image Sequence...", "open=/home/mario/Desktop/prueba/1/Image-000002.tif");
selectWindow("1");
//setTool("rectangle");
makeRectangle(406, 346, 1132, 845);
run("Z Project...", "projection=[Average Intensity]");
saveAs("Tiff", "/home/mario/Desktop/prueba/1/AVG_1.tif");
What this macro does is to import an image sequence stored in the referenced folder, to align the stack of images using the Template matching plugin, to do focus stacking using the Z Project function (Image > Stacks > Z Project...) and to save the newly generated image in the same folder using the tiff extension.
However, I do have a general folder with plenty subfolders filled with tiff files, so applying one by one the previous macro in each folder could become a tedious task as well. I came across with this macro that deals with batch processing:
// "BatchProcessFolders"
//
// This macro batch processes all the files in a folder and any
// subfolders in that folder. In this example, it runs the Subtract
// Background command of TIFF files. For other kinds of processing,
// edit the processFile() function at the end of this macro.
requires("1.33s");
dir = getDirectory("Choose a Directory ");
setBatchMode(true);
count = 0;
countFiles(dir);
n = 0;
processFiles(dir);
//print(count+" files processed");
function countFiles(dir) {
list = getFileList(dir);
for (i=0; i<list.length; i++) {
if (endsWith(list[i], "/"))
countFiles(""+dir+list[i]);
else
count++;
}
}
function processFiles(dir) {
list = getFileList(dir);
for (i=0; i<list.length; i++) {
if (endsWith(list[i], "/"))
processFiles(""+dir+list[i]);
else {
showProgress(n++, count);
path = dir+list[i];
processFile(path);
}
}
}
function processFile(path) {
if (endsWith(path, ".tif")) {
open(path);
run("Subtract Background...", "rolling=50 white");
save(path);
close();
}
}
However, I do not know how to merge my automated tasks written in my macro with the latter, as I am not an expert in coding.
To sum up, I would like to run my macro in every folder and subfolder automatically from a root directory of my selection.
Can anybody edit and merge the previous macros in order to accomplish my requirements?
Just in case somebody came across this question, the answer can be found in the ImageJ forum.
The problem:
//Create Evernote App SBApplication
EvernoteApplication *evernoteApp = [SBApplication applicationWithBundleIdentifier:#"com.evernote.Evernote"];
evernoteApp.delegate = self;
//Take this ENML Code
NSString *enml = #"<div>This is an encrypted text for OneNote Saferoom.</div><div><br/></div><div>PDF file</div><div><en-media type=\"application/pdf\" style=\"cursor:pointer;\" height=\"43\" hash=\"fa7d7e650b2cec68f302b31ba28235d8\"/></div><div><br/></div><div>Image</div><div><en-media style=\"height: auto;\" type=\"image/png\" hash=\"64957a2bd851f625383a5b9e410965d7\"/></div>";
//Create correct Array of URLS for above (Set the URLs before)
NSArray *resourceURLs = [NSArray arrayWithObjects:url2,url1,nil];
//Upload the note to Evernote
[evernoteApp createNoteFromFile:nil fromUrl:nil withText:nil withHtml:nil withEnml:[NSString stringWithFormat:#"<en-note>%#</en-note>",enml] title:noteTitle notebook:workingNotebook tags:tags attachments:resourceURLs created:nil];
And now I get the note with additional duplicated resources (Evernote app just adds all resources from resourceURLs array to the end of the note):
Tried the following
remove resourceURLs array - no resources added
using HTML and adding resource URLs - structure is not kept, resources appear at the end only
converting from ENML to HTML using Inline resources function (ENMLUtility) - resources are not displayed
I am starting to believe that there is a bug in how Evernote.app handles createNote request.
Resources to test
PDF sample file for above resource:
https://www.dropbox.com/s/t8pgzzexms0nl7w/dec-pdf-sample.pdf?dl=0
Image sample
https://www.dropbox.com/s/nagaei1hng6ziwc/dec-touchID_blue_80%403x.png?dl=0
Generated Evernote.h file for bridging:
https://www.dropbox.com/s/7u1zdb8c71ydwag/Evernote.h?dl=0
Any help will be appreciated.
Update 1:
Tested with pure AppleScript, still resources are duplicated:
https://www.dropbox.com/s/rvpc4est8ef7q4c/EvernoteAppleScript_bug.scpt?dl=0
Thanks,
Ilia
I want to open a new Finder window of a specific size in a specific position and displaying a specific folder.
In ScriptingBridge (XCode 6, Mavericks 9.4) I can open a new Finder window and have figured out how to read the URL of the folder it opens. But I am really struggling with how to set the folder to something different.
I have tried to assign the window a 'target' SBObject initialised with a 'URL' property.
but the URL property is readonly although 'target' seems not to be. I've used 'get' to ensure there is a FinderFolder object and a FinderFinderWindow object.
I've tried using a dictionary of properties with a URL key and creating a 'folder'.
FinderFolder *folder = [[[_finder classForScriptingClass:#"folder"] alloc]
initWithProperties:dict];
[[_finder folders] addObject:folder];
I have read the Apple docs and looked for examples all over but cannot find an instance of someone assigning the folder path.
// open folder "Documents" of home folder
FinderFolder *theHomeFolder = [theFinder home];
NSLog(#"theHomeFolder: %#",theHomeFolder);
SBElementArray * theHomeFolderFolders = [theHomeFolder folders];
NSLog(#"theHomeFolderFolders: %#",theHomeFolderFolders);
FinderFolder *theDocsFolder = [theHomeFolderFolders objectWithName:#"Documents"];
NSLog(#"theDocsFolder: %#",theDocsFolder);
[theDocsFolder openUsing:nil withProperties:nil];
FinderFinderWindow * docsFolderWindow = (FinderFinderWindow*) [theDocsFolder containerWindow];
NSLog(#"docsFolderWindow: %#",docsFolderWindow);
docsFolderWindow = [docsFolderWindow get];
NSLog(#"docsFolderWindow: %#",docsFolderWindow);
// change its bounds
docsFolderWindow.bounds = NSMakeRect(64., 64., 800, 600.);
// other fun stuff…
[docsFolderWindow setCurrentView:FinderEcvwListView];
[[docsFolderWindow iconViewOptions] setArrangement:FinderEarrArrangedByName];
[docsFolderWindow cleanUpBy:#selector(name)];
docsFolderWindow.toolbarVisible = NO;
docsFolderWindow.statusbarVisible = NO;
docsFolderWindow.sidebarWidth = 0;
There are a few different ways. The other answer works, or you could explicitly make a new Finder window and set its target property:
NSURL *u = [NSURL fileURLWithPath:#"/tmp"];
FinderFinderWindow *w = [[[theFinder classForScriptingClass:#"Finder window] alloc] init];
[[theFinder finderWindows] addObject:w];
[w setTarget:u];
You could also set it to an SBObject referring to a Finder item, such as theDocsFolder from the other answer.
I'm trying to write a script that takes the current editors of a folder and changes their permission to view only only at the lowest level folders. Everything is working fine, except it seems that it is taking Google Drive too long to apply the permissions of the top folder (View only) to all of the sub folders. Because of this, the editors of TOP_FOLDER, who originally had Edit access to all of the sub folders since it was inherited from TOP_FOLDER, retain this access when I run the script even though when I preform the exact same action in Drive they all have View only access after I refresh the page.
Does anyone have any ideas on how to fix this?
function fixFilePermissions() {
var oldEditors = TOP_FOLDER.getEditors();
TOP_FOLDER.addEditors(ADMINS);
//remove All but the admins
for each (var editor in oldEditors){
//if editor is not an admin
if(ADMINS.indexOf(editor) < 0){
//remove editor
TOP_FOLDER.removeEditor(editor);
//add back as viewer
TOP_FOLDER.addViewer(editor);
}
}
recFixFilePermissions(TOP_FOLDER);
}
function recFixFilePermissions(folder){
while(folder.getEditors().length > ADMINS.length){
Utilities.sleep(200);
Logger.log(folder.getEditors().length - ADMINS.length);
}
Logger.log("Folder: "+folder.getName());
Logger.log("Editors: "+folder.getEditors());
Logger.log("Viewers: "+folder.getViewers());
if(folder.getFolders().length > 0){
for each (subfolder in folder.getFolders()){
recFixFilePermissions(subfolder);
}
Logger.log("Has Subfolder");
}else{
for each (var person in folder.getViewers()){
folder.addEditor(person);
Logger.log("Gave " + person + " Edit Access to " + folder.getName());
}
}
}