[resolved] Is it possible to get the folder name of the current job?

One Star

[resolved] Is it possible to get the folder name of the current job?

Hello, 
Is it possible and how can I get the folder name of the current job?
I'm talking about the folders in which jobs are organized in TOS JobDesigns (not disk directories).
For example if I'm executing job "CreateXMLFeed" I want to assign to a variable the folder name - "Google"
(sorry for the ASCII drawing - for some reason the forum currently does not allow uploading images/screenshots):
Job Designs
+- Google
  +- CreateXMLFeed
  +- UploadFeed
+- Tests
  +- TestJob1
  +- TestJob2    

Thanks, 
Mirko

Accepted Solutions
Community Manager

Re: [resolved] Is it possible to get the folder name of the current job?

Hi mirkodev 
There is still an real folder name called 'Google' in workspace/yourProjectName/process directory in the file system, so you can iterate all the job file names in this directory, compare the file name with current job name and get the current folder name. 
----------------------------------------------------------
Talend | Data Agility for Modern Business

All Replies
Community Manager

Re: [resolved] Is it possible to get the folder name of the current job?

Hi Mirko
No a global variable can be used to get it directly, I think you can create a subjob to get it, below is my idea: use a tFileList to iterate each file name in the workspace folder, includes its sub-folder, if the file name equals to the jobName (this is a global variable for the current job name), exit the loop and get the current folder path.
----------------------------------------------------------
Talend | Data Agility for Modern Business
Five Stars

Re: [resolved] Is it possible to get the folder name of the current job?

What I usually do in situations like this is to have a 'google' context group that is added to all of the Jobs in the Google folder. I can then add this, and any other parameters that I want to apply to all of these Jobs.
One Star

Re: [resolved] Is it possible to get the folder name of the current job?

Hi Mirko
No a global variable can be used to get it directly, I think you can create a subjob to get it, below is my idea: use a tFileList to iterate each file name in the workspace folder, includes its sub-folder, if the file name equals to the jobName (this is a global variable for the current job name), exit the loop and get the current folder path.

Hi Shong, 
I'm not sure I understand you and I think you are talking about the file system directory, while I need, as mentioned, the "folder" in which jobs are organized under Job Designs.
tal00000:
What I usually do in situations like this is to have a 'google' context group that is added to all of the Jobs in the Google folder. I can then add this, and any other parameters that I want to apply to all of these Jobs.
Hi Thanks, nice workaround.
So If I understand correctly there is NO way to get the actual job folder name, right?
Community Manager

Re: [resolved] Is it possible to get the folder name of the current job?

Hi mirkodev 
There is still an real folder name called 'Google' in workspace/yourProjectName/process directory in the file system, so you can iterate all the job file names in this directory, compare the file name with current job name and get the current folder name. 
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] Is it possible to get the folder name of the current job?

Hi mirkodev 
There is still an real folder name called 'Google' in workspace/yourProjectName/process directory in the file system, so you can iterate all the job file names in this directory, compare the file name with current job name and get the current folder name. 

Aaagh... I see now! Thanks for the trick Shong!
But this means this won't be available when I build the job as standalone job... 
Community Manager

Re: [resolved] Is it possible to get the folder name of the current job?

Yes, it will not be available if the job script is executed on another machine,  I am interesting in why you need to get the current folder name in the job. 
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] Is it possible to get the folder name of the current job?

Thanks shong! It's just for better organization and my logging module (I'm grouping my components in folders)