#target bridge
if( BridgeTalk.appName == "bridge" ) {
var cPics = new MenuElement( "menu", "Client Pictures", "after Help", "cPics" );
var getPics = new MenuElement( "command", "Get Client Pics", "at the end of cPics" , "xxxx" );
}
getPics.onSelect = function () {
getDemPics();
}
function getDemPics(){
var win = new Window('dialog','Get Pics');
win.pn1 = win.add('panel', undefined, undefined, {borderStyle:"black"});
win.grp1 = win.pn1.add('group');
win.grp1.st1 = win.grp1.add('statictext',undefined,"Find Pictures");
win.grp1.st1.graphics.font = ScriptUI.newFont("Georgia","BOLDITALIC",22);
win.grp2 = win.pn1.add('group');
win.grp2.st1 = win.grp2.add('statictext',undefined,'Select Text File... ');
win.grp2.et2 = win.grp2.add('edittext');
win.grp2.et2.preferredSize=[250,20];
win.grp2.et2.enabled=false;
win.grp2.bu1 = win.grp2.add('Button',undefined,'Select');
win.grp2.bu1.onClick = function() {
txtFile = File.openDialog("Open Text File","Text(*.txt):*.txt;");
if(txtFile != null){
win.grp2.et2.text = decodeURI(txtFile.fsName);
}
}
win.grp3 = win.pn1.add('group');
win.grp3.bu1 = win.grp3.add('button',undefined,'Process');
win.grp3.bu1.preferredSize=[200,30];
win.grp3.bu2 = win.grp3.add('button',undefined,'Cancel');
win.grp3.bu2.preferredSize=[200,30];
win.grp3.bu1.onClick = function(){
if(win.grp2.et2.text == ''){
alert("No TEXT file has been selected!");
return;
}
win.close(1);
var fileList =[];
datafile = new File(txtFile);
datafile.open('r') ;
while(!datafile.eof){
strInputLine = datafile.readln();
if (strInputLine.length > 3) {
fileList.push(strInputLine.replace(/^\s+/,''));
}
}
datafile.close();
var Path =app.document.presentationPath;
var outFolder= Folder(app.document.presentationPath+"/"+"Client Order");
if(!outFolder.exists) outFolder.create();
var notFound=[];
for(var a in fileList){
var file = File(Path+"/"+fileList[a]);
var To = File(outFolder+"/"+fileList[a]);
if(file.exists){
file.copy(To);
}else{
notFound.push(fileList[a]);
}
}
if(notFound.length >0){
var error = new File(outFolder + "/Error Log.txt");
error.open("w", "TEXT", "????");
$.os.search(/windows/i) != -1 ? file.lineFeed = 'windows' : file.lineFeed = 'macintosh';
error.writeln("Files not found...");
for(var a in notFound){
error.writeln(notFound[a].toString());
}
error.close();
error.execute();
}
app.document.thumbnail = new Thumbnail(outFolder);
}
win.show();
}