How does one load some variables at runtime in Photoshop Script? - photoshop

I have about 200 folders with X images in each of them.
I have a master script in the root folder that does some stuff to the images.
Each folder has some variables specific to it and its contents.
I want my master script, when it parses folder Y, load some sort of a config file from within folder Y to get those variables, then when folder Z is to be parsed, load the config file from that one.
I know of #include "config.jsx" that I use at the moment to load it but its at the beginning of the script, I need something dynamic and doesn't need to be a jsx at all.

I store all my parameters in xml format and read that in using the XML objects in extendscript. As long as your parameters file is always named something like 'config.xml' it is easily located.
var file = new File( /c/folder/file.xml );
file.open("r");
var str = file.read();
var xml = new XML(str);

Related

Copy multiple files from multiple folder to single folder in Azure data factory

I have a folder structure like this as a source
Source/2021/01/01/*.xlsx files
Source/2021/03/02/*.xlsx files
Source/2021/04/03/.*xlsx files
Source/2021/05/04/.*xlsx files
I want to drop all these excel files into a different folder called Output.
Method 1:
When I am trying this, I used copy activity and I am able to get Files with folder structure( not a requirement) in Output folder. I used Binary file format.
Method 2:
Also, I am able to get files as some random id .xlsx in my output folder. I used Flatten Hierrachy.
My requirement is to get files with the same name as source.
This is what i suggest and I have implemented something in the past and i am pretty confident this should work .
Steps
Use getmetada activity and try to loop through all the folder inside Source/2021/
Use a FE loop and pass the ItemType as folder ( so that you get folder only and NO files , I know at this time you dont; have file )
Inside the IF , add a Execute pipeline activity , they should point to a new pipeline which will take a parameter like
Source/2021/01/01/
Source/2021/03/02/
The new pipeline should have a getmetadata activity and FE loop and this time we will look for files only .
Inside the FE loop add a copy activity and now will have to use the full file name as source name .

How to get the path of the opened files in DM?

I am trying to perform a script on all opened files in DM. For now, I have built a Taglist of all these files, and I am planning to use a for statement to get the path of each file and return it to the existing script. However, I do not know how to extract the path of these opened files from the Taglist. Thanks.
The property of a saving location is not a property of the image object, but of the imageDocument object.
The command you're seeking is
String ImageDocumentGetCurrentFile( ImageDocument img_doc )
Returns the file location to which the image document is currently linked.
And an example script is:
Result("->" + GetFrontImage().ImageGetOrCreateImageDocument().ImageDocumentGetCurrentFile() )

How to automate reading files in the folder?

I have some folder on my desktop, let's call it FOLDER_X.
I want to read all the names of files which are in the FOLDER_X.
Is it possible to do it with G1ANT, how can I do that?
You can do it also with usage of snippets, i.e. C#:
♥files = ⟦list⟧⊂System.IO.Directory.GetFiles("your path here")⊃
foreach ♥file in ♥files
dialog ♥file
end
If you want to remove the path from ♥file place this line at the beginning of the loop:
text.replace regex ‴^.*\\‴ text ♥file replace ‴‴ result ♥file
The below script will display all names of files that are in the FOLDER_X.
The directory command will retrieve all the directories and files that are in the specified path and create the ♥result variable containing all the data in a list.
The foreach loop will iterate through the found elements which are of G1ANT path structure. There are several indexes that you can use, for example isfile and name that are useful here.
directory path ‴♥environment⟦USERPROFILE⟧\Desktop\FOLDER_X‴
foreach ♥element in ♥result
dialog ♥element⟦name⟧ if ⊂♥element⟦isfile⟧⊃
end foreach

Open txt file and draw histogram in root

I have a txt file which contains numbers. I want to draw a histogram according to this file in root. But I can't do this.
{
TFile *f = new TFile("myfile.root");
f.ls();
TH1F * h1 = (TH1F*)f.Get("h1");
h1->Draw();
}
Have a look at this tutorial from the ROOT website. As far as I know ROOT can't open a plain text file directly. The TFile("myfile.root") call can be used to open a ROOT file (i.e. a binary file created by ROOT containing persistified ROOT objects such as histograms), which as you point out causes errors if you try to open a plain text file using it. The approach shown in the tutorial page is to create a TH1, then use standard C++ I/O streams to read from your text fiule and fill the histogram in the normal way.

BigQuery loading batch folders error

I'm trying to load group of folders files in one time with when
i set
sourceURI = 'gs://ybbi/bi_landing_zone/files_to_load/app/reports/app_network_analytics_report/201409011*'
all the folders that i'm want to load start with 20140911
but i get the error:
ERROR: Invalid path: gs://ybbi/bi_landing_zone/files_to_load/apn/reports/appnexus_network_analytics_report/20140901191111_3bab8ec0_092a_43de_a157_db35d1555ea0/
20140901191111_3bab8ec0_092a_43de_a157_db35d1555ea0 is one of these folders(don't know why it's print the all folder name of this specific folder)
in some other folder tree cases it's works, but in this specific folder tree it's return the same error .
i know that cloud storage don't have real folders and it's part of the name of the object, but you understand what i mean.
is it bug?
Without more information, what it looks like is that you have a object file called gs://ybbi/bi_landing_zone/files_to_load/apn/reports/appnexus_network_analytics_report/20140901191111_3bab8ec0_092a_43de_a157_db35d1555ea0/ that is not a csv/json file. Some tools may create these dummy files in order to simulate directories. BigQuery requires all objects that match the input glob path to be importable files.
One solution would be to change the glob path to include a narrower set of files. You can pass multiple paths if that makes things easier. For example, you could pass
gs://ybbi/bi_landing_zone/files_to_load/apn/reports/appnexus_network_analytics_report/20140901191111_3bab8ec0_092a_43de_a157_db35d1555ea0/*
and
gs://ybbi/bi_landing_zone/files_to_load/apn/reports/appnexus_network_analytics_report/20140901191111_some_other_path/*