GMC how to get FileName? Please!

Face713

Member
Hello everyone,GMC how to get FileName?
I use Data Input,Data Transformer and Layout modules.
Data is a .txt file,it ONLY 2 fields,one is ID number,other is Name,and have many photos on D:\photos\,
photos filename like this 1.tif,2.jpg,3.eps,4.jpg...
Files Extension:.jpg,.eps or .tif

.txt like this:
ID Name
1 Jane
2 Rose
3 Susan
4 Hebe
... ...
how to use script link this files?
I use return "D:\photos\" +ID+".*";
but no work,gmc Does not support * and ?:confused:
 
Hi Face713

You need to put the correct Path and File name for the image. Imagine there are two file 1.jpg and 1.eps, which one is the correct to show?

There are several ways to do it:
1. use the File.exist method to know if the file exist in the path. You need to concatenate 3 if sentences to evaluate the correct extension:
if (File.exist("D:\photos\"+ID+".jpg"))
return "D:\photos\"+ID+".jpg";
if (File.exist("D:\photos\"+ID+".eps"))
return "D:\photos\"+ID+".eps";
....
2 use the File.listWithMask method to filter files in a path with wildcard characters
File.FileInfoList fileList;
if (File.listWithMask(fileList, File.ListParam.Files, "D:\photos\", ID+".*"))
{
for(Int i=0;i<fileList.Size;i++)
{
return (fileList.Location);
}
}
The second one return the first file in the question at the begining.

If you want more you can use the GMC Community: community.gmc.net

Regards
 
Hello,nmedina,this script very good for me.
but there is a problem for get filenames,if this folder without a or many file(s),like no 12.tif or eps or tif,when i proof it,this layout is none(beacuse no photo),but gmc have not tell me,how to fix it? let it tell me?
thanks again.

return "D:\photos\" +ID+".jpg"; this script can tell me if without 12.tif in photos folder.
 
Hi Face713

In case of File.exist the method returns false if the file doesn't exist.

In the 2nd case, fileList.Size has value 0.

In both cases you can show a warning or an error to inform you while you are producing:
logWarning("No photo has detected for id:"+ID);

Another solution is to put a Default image in the variable image which it will show if no photo has detected but i don't know if it is valid for you.

Regards
 
thanks to nmedina! this script so cool for me.

can you tell me how to sign in community.gmc.net?

i have not @gmc.net email.

Regards
 
Hi Face713

You don't need to have a @gmc.net email.

Just create an account bellow the login form.

See you there.

Regards.
 
Hello,nmedina,i have create an account use my email,but gmc have not send me password.how can i do? thank you!

Regards.
 

PressWise

A 30-day Fix for Managed Chaos

As any print professional knows, printing can be managed chaos. Software that solves multiple problems and provides measurable and monetizable value has a direct impact on the bottom-line.

“We reduced order entry costs by about 40%.” Significant savings in a shop that turns about 500 jobs a month.


Learn how…….

   
Back
Top