Dropzone - How can overwrite the previous upload when drop another file again - dropzone.js

How can overwrite the previous upload when I drop another file again.
Example:
Drag file A into the dropzone. It will uploaded file A. Then I drag file B into the same dropzone, it will removed file A (No need to remove from server side) and upload file B.

you can assign a listener to the addedfile event, and handle this problem.
this.on("addedfile", function(file) {
// you code, maybe like below
var files = myDropzone.getFilesWithStatus('success');
if(files.length > 0 ){
for(int i = 0; i < files.length ; i++){
myDropzone.removeFile(files[i]);
}
}
});

Related

GoogleSheet: Insert Image Based on Cell Value and File Name

I am looking for a GoogleScript which can automatically insert the image in the cell based on File Name. The steps are below:
Get Name (in Column A)
Lookup the image file in "Image Folder"
Insert the image with fixed size (Column B)
I am attaching the sheet for your understanding.
GDoc
Folder
Script that I use but is not working:
function listFilesInFolder(folderName) {
//writes the headers for the spreadsheet
var sheet = SpreadsheetApp.getActiveSheet();
sheet.appendRow(["Image"]);
var folderId = "1AV5pTs3l7GGMNH7-C8rixjcWNNTsmbpE";
var folder = DriveApp.getFolderById(folderId);
var contents = folder.getFiles();
var cnt = 0;
var file;
while (contents.hasNext()) {
var file = contents.next();
cnt++;
Logger.log(file);
Logger.log(cnt);
// writes the various chunks to the spreadsheet- just delete anything you don't want
data = [
"https://docs.google.com/uc?export=download&confirm=no_antivirus&id=" + file.getId(),
file.getDescription(),
"=image(\"https://docs.google.com/uc?export=download&id=" + file.getId() +"\")",
];
sheet.appendRow(data);
};
};

Writing Macro in ImageJ to open, change color, and resave microscope images

I'm trying to write a code in Image J that will:
Open all images in separate windows that end in " - GFP.vsi" within a folder
Use look up tables to convert images to green and RGB color
From ImageJ, the commands are: run("Green"); and run("RGB Color");
Save each image in the same, original folder with the same name and as a .tif
Would be ok if images overwrite original, but would also be ok if they had a new name.
From ImageJ, to save as .tif file: saveAs("Tiff", "Filepath");
I have no experience with Java and just a little experience with coding. I tried to piece something together using code I found on stackoverflow and on the ImageJ website, but kept getting error codes. Any help is much appreciated!
This is the way I would approach this task:
macro "Change and Resave" {
dir1 = getDirectory("Choose Source Directory ");
dir2 = getDirectory("Choose Destination Directory ");
list = getFileList(dir1);
// Make an array of files ending " - GFP.vsi"
nd2list = newArray(0);
for (i=0; i<list.length; i++) {
if (endsWith(list[i], " - GFP.vsi")) {
vsilist = append(vsilist, list[i]);
}
}
setBatchMode(true);
// loop through files
for (i=0; i<vsilist.length; i++) {
showProgress(i+1, vsilist.length);
// open file using Bio-Formats, you may need to edit these two lines
s = "open=["+dir1+vsilist[i]+"] autoscale color_mode=Composite rois_import=[ROI manager] view=Hyperstack stack_order=XYCZT";
run("Bio-Formats Importer", s);
// your commands from your question
run("Green");
run("RGB Color");
saveAs("tiff", dir2+replace(vsilist[i],".vsi",".tif"));
close();
}
setBatchMode(false);
}
function append(arr, value) {
arr2 = newArray(arr.length+1);
for (i=0; i<arr.length; i++)
arr2[i] = arr[i];
arr2[arr.length] = value;
return arr2;
}

how to "batch replace" for a lot of files in emeditor

yes,I know "Batch Replace All",but
my replace list is so big,has 200+ items, i will use it in a big folder which has a lot of files.
now,emediter's behave is that use item1 in all files,then use item2 in all files.....
expected: use item1....item200 in file1,and use item1...item200 in file2
how to do it ?
I attempt use the macros(openfile,replace,closefile),but it is very slowly because open a file need 50ms
emeditor 19.9.1
var fso = new ActiveXObject("Scripting.FileSystemObject");
var files = [];
var filesHasModified = [];
function showFolderFileList(folderspec) {
var f = fso.GetFolder(folderspec);
if(/\\(doc|lib|\.git|\.idea|\.vs|dll)$/gi.test(folderspec)){
return;
}
// recurse subfolders
var subfolders = new Enumerator(f.SubFolders);
for(; !subfolders.atEnd(); subfolders.moveNext()) {
showFolderFileList((subfolders.item()).path);
}
// display all file path names.
var fc = new Enumerator(f.files);
for (; !fc.atEnd(); fc.moveNext()) {
var file = fc.item();
if(/\.(jmx|config|cs|Config|tt|ttinclude|txt|yml|java|bak|xml|cshtml|sh|yaml|js|json|md|properties)$/gi.test(file)){
files.push(file);
}
}
}
showFolderFileList('D:\\Sources.git2');
for( i in files)
{
var file = files[i];
editor.OpenFile(file);
document.selection.Replace("http://172xx","http://offline.esb.xx",eeReplaceAll,0);
document.selection.Replace("http://172xx1","http://offline.esb.xx",eeReplaceAll,0);
document.selection.Replace("http://172xx2","http://offline.esb.xx",eeReplaceAll,0);
//....200 more
if(document.Saved)
{
document.close();
}
else
{
filesHasModified.push(file);
document.Save(file);
document.close();
}
}
editor.NewFile();
document.selection.Text = filesHasModified.join("\r\n");
I will optimize Batch Replace in Files in a future version. Meanwhile, please try (normal) Batch Replace with the Search All Documents in the Group option. This is how you can do:
Update EmEditor to v19.2.2 (or later).
Open EmEditor, select Tools menu - Customize - Tab page, and select None from the When Not Fit drop-down list, and select Fix to specified with from the Width drop-down list.
Open all (or some) files with EmEditor. An easy way is to drag and drop multiple files from Windows Explorer into EmEditor.
In EmEditor, press Ctrl + H to show Replace dialog box, click Batch >>, set the Search All Open Documents in the Group, make sure the batch list is updated, and click the Batch Replace All button.
The (normal) Batch Replace will work as you expect (use item1....item200 in file1, and use item1...item200 in file2, etc.).

Indesign server data merge

I am trying to do a data merge using Indesign Server. test.indd in the script below already has all the merge fields assigned. I only need this script to open the file, do the merge, and save the merged file. The file that gets saved is the original test.indd file, and not the merged file. I'm not sure how to access the merged file.
var myDocument = app.open(File("/C/inetpub/wwwroot/datamerge/test.indd"));
with (app.dataMergeOptions) {
linkImages = true;
removeBlankLines = false;
createNewDocument = true;
documentSize = 100;
} // (end of dataMergeOptions)
myDocument.dataMergeProperties.mergeRecords();
myDocument.save(new File("/C/inetpub/wwwroot/datamerge/mergedOutput.indd"));
myDocument.close ();
If someone can have a look and let me know what I'm missing. Or direct me in the direction I should be going.
Your dataMergeOptions tell the application to create a new document but you are saving the document in your myDocument variable which is your template. You need to either get a hold of the newly created document and save that or remove the createNewDocument option.

How to read form fields of indd file

I have made a .indd file with some form fields in it.
Now I want to get all these fields through indesign script and manipulate its content
so that i can change the content of fields and apply these changes to .indd file.
Well I have got this and able to get all fields of the doc.
var myDoc = app.open(File("fileName.indd"));
var allformFields = myDoc.formFields;
for(var i = 0; i < allformFields.length; i++){
var tf = allformFields[i];
alert(tf.name);
}

Resources