
Label Files with a Unique ID
This script demonstrates how you can use global, persistent data in a script. In this case the global data is used to hold a unique ID and the name of every processed job is prefixed with that unique ID.
Information
Supported by: PowerSWITCH (MAC and WIN)
Language: JavaScript
Description:
You can use this script multiple times and in as many flows as you want. The script is triggered each time a new job arrives in one of the input folders that is connected to a script element which has this script selected.
The unique ID is defined globally, so it doesn't matter which file in which flow triggers the script, the ID will be different every time (within the same installation of PowerSWITCH). The unique ID is also persistent, it remains unique even if PowerSWITCH is stopped and restarted.
The incoming job is renamed adding the unique id as a prefix (e.g. 1_JobName).
Using this script
- Download and save the script on your computer: download script.
- Select the Script element in your PowerSWITCH flow and browse to the script in the Script package property.
or - Open the script in the SWITCHscripter and change it to your needs .
Example flow
- Add unique ID to job name
A unique number is added to all files that go through this flow. The counter is remembered by SWITCH and starts with 1.
