I'm planning to try using the Sharperlight Scheduler to perform actions such as copying files and exporting file lists to a file.
The folder structure, as shown in the diagram below will be used.
Each folder contains files like the ones shown below.
I'm planning to access these folders and files from the scheduler task.
Folder Security
Normally, Sharperlight is installed and operated on the application server. Allowing unrestricted access to the application server's folders poses a security risk. Therefore, Sharperlight provides the ability to register folders allowed for access using site setup. Let's proceed with the configuration.
Launch the Site Setup from the Sharperlight application menu.
Select Product Settings
and System
from the tree view.
The options for product settings will be displayed on the right side. In the bottom option, Secure Folders
, specify the path of the folder you want to access in this case. If there are multiple folders, concatenate them with the pipe symbol (|).
Close the Site Setup dialog by clicking the Close
button.
Restart the Sharperlight service to apply the changes.
Creating a Scheduler Task
Launch the Scheduler from the Sharperlight application menu.
Initiate the task creation by clicking the New
button.
In the General tab, enter the Code
, Group
and Description
.
Navigate to the Action tab and define the process you want to execute here.
Exporting a list of files to CSV
This time, I will check all the subfolders under C:\QiitaSampleTemp\ and create a CSV file listing all the files. At the same time, I will copy all the files to the C:\QiitaSampleCopy\ folder.
Add a new action by clicking the New
icon.
Select Query Combinations from the list of available actions.
Configure the settings for Query Combinations. This action functions like a for loop.
By defining the query here, you can pass a row one by one from the dataset returned by the query to the next action.
Let's begin creating the query by clicking the Edit Query
button.
The familiar Query Builder will open. Select Summary Report as the Mode
, and choose System as the Product
.
Select File List for the Table
in the query
Folder
will be displayed as a mandatory filter. Choose the folder you want to access.
To ensure access to sub folders, confirm that the Sub Folders
is set to Y as another mandatory filter.
Next, specify the following items in the output area from the selection list.
Try the query by clicking the Preview
button.
The file list will be returned. Exclude the first row from the query as it is unnecessary. Return to the query definition by clicking the Back to Query
button.
Drag and drop Size from the selection list to the filter area. Set the condition to Greater than 0.
Try the query again by clicking the Preview
button. The unnecessary first row should now be excluded.
Furthermore, in this query, keep only the following output items and remove the others.
Executing the query will return a dataset similar to this.
With this, the query is complete. Values will be passed one by one from this dataset to the next action as parameters. Click OK
to save the query and return to the Action tab.
Add a new action by clicking the New
icon.
The Query Combinations action, which was defined earlier, requires a corresponding Query Combinations End action to terminate the loop. Add this action first.
Now, let's define the core action that processes each row of the dataset obtained by the Query Combinations action. Add a new action using the New
icon. This time, use the Query action. This action will be defined between the Query Combinations and Query Combinations End actions.
Define the query by clicking the Edit Query
button.
The query filters will be the same as before.
However, this time, we will pass the folder name obtained by the Query Combinations action to the Folder
filter. Use the unique reference name displayed at the right end of the Folder
filter, which is @Folder.
Before that, set the following items in the output area from the selection list.
Save the query by clicking the OK
button.
In the Query Parameters
, enter Folder=. This represents the reference name of the Folder
filter in this query. It means passing a value to the Folder
filter in this query.
The value to pass is the folder name obtained by the previous Query Combinations action, so use the reference button on the right to search and set it.
Complete the settings by clicking the OK
button.
Next, write the results of this query to a CSV file. The settings for this are on the right side.
The settings will be as follows. The Append
checkbox means appending data to the same file.
File Copy
Add the File Copy action.
Set the source and destination of the file as follows. Utilize the return value of the previous Query Combinations action.
With this, the definition of the core actions are also completed.
Save the task by clicking the OK
button.
Validation of the Scheduler Task
Select Execute from the right-click menu.
If no errors or issues are displayed, everything is working correctly.
Let's quickly locate the created file list, FileList.csv.
Great, it's there.
Let's also check the C:QiitaSampleCopy folder. You can see that the files have been copied.
Afterword
This time, I used the Sharperlight scheduler to create a list of files and tried copying files. While this isn't a task typically done using scheduling, I wanted to convey that such usage is possible among the numerous features available. Thank you and goodbye.