Order then Rename Jobs

Post Reply
Tenzo
Member
Posts: 22
Joined: Wed Jan 31, 2024 11:22 am
Location: USA :(
Contact:

Order then Rename Jobs

Post by Tenzo »

Hey all,

First of all, I'm new to Switch excited to start using this platform. I'm really only used to RPA solutions like Power Automate Desktop, So I'll probably have to learn some scripting skills to get some things done.

Anyways, I have been diving into one of our flows and I am stuck on how to go about this in Switch.
We have a Set Hierarchy for all of our Jobs. Example:

-->Date
-------->Batch 1
------------->Product Group 1
----------------->file_01.png
----------------->file_02.png
----------------->etc.
------------->Product Group 2
----------------->file_01.png
----------------->file_02.png
----------------->etc.
-------->Batch 2
--->etc.

While this hierarchy works as expected, I am also looking for a solution to order then rename the Jobs in their "Product Group" folder by multiple Private Data Feilds.

Example:

Order Jobs by Private Data:
  • Rush
  • Sku
  • UID
  • Ink Color
Once the Jobs are in their specific order, I am needing to rename them as:
  • Batch_
  • ProductGroup_
  • UID_
  • Numerical Order 0001, 0002, 0003, etc.
Is there a way to do this natively in Switch or would I have to go the scripting route?
Any input would be greatly appreciated!
User avatar
magnussandstrom
Advanced member
Posts: 512
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden
Contact:

Re: Order then Rename Jobs

Post by magnussandstrom »

Hi and welcome to the forum!

I can think of a couple of ways to achieve this, but I need more info to present a solution. How do the files come into the flow, one folder with all files or file by file etc. Maybe you could post a screenshot of your flow so far?

Also what are the different values for Rush, Sku, UID
and Ink Color and how would you like to sort them?
Tenzo
Member
Posts: 22
Joined: Wed Jan 31, 2024 11:22 am
Location: USA :(
Contact:

Re: Order then Rename Jobs

Post by Tenzo »

magnussandstrom wrote: Sun Dec 01, 2024 3:50 pm How do the files come into the flow?
  • Web Submit point sending a dummy file with the Date and Batches MetaData
  • HTTP request to our Data Base for all the Job information
  • It returns JSON to be picked up, and transformed into XML and Split on UID
  • The result is an XML file for each Job, and it's named with the UID field
  • There are more steps in the flow, but the XML file is the final step to make each UID a Job in Switch
I am trying to get our DB admin to order by before they return the query, but I'd still like to have a Switch solution to order them.
magnussandstrom wrote: Sun Dec 01, 2024 3:50 pm Also what are the different values for Rush, Sku, UID
and Ink Color and how would you like to sort them?
The Ordering and their Values are:
  • Rush = Boolean (1 or 0)
  • Sku = String (Too many Values to list but ordered alphabetically ascending)
  • UID = String (9622453)
  • Ink Color = String (Black, Red, etc.)
Thanks for looking into this. I am still trying to wrap my head around the Switch workflow compared to my previous software.
Attachments
Flow.png
Flow.png (29.09 KiB) Viewed 10668 times
freddyp
Advanced member
Posts: 1130
Joined: Thu Feb 09, 2012 3:53 pm

Re: Order then Rename Jobs

Post by freddyp »

You should not order and then rename, you should rename and then order.

The way the hierarchy works is that it is attached as information to the job regardless of its name, and it materializes at the moment the job hits "Archive hierarchy". Renaming a job does not change its hierarchy information, so make sure the job has the correct name using all the private data and metadata available during the execution of the flow before it hits "Archive hierarchy".
Tenzo
Member
Posts: 22
Joined: Wed Jan 31, 2024 11:22 am
Location: USA :(
Contact:

Re: Order then Rename Jobs

Post by Tenzo »

freddyp wrote: Tue Dec 03, 2024 9:06 am You should not order and then rename, you should rename and then order.

The way the hierarchy works is that it is attached as information to the job regardless of its name, and it materializes at the moment the job hits "Archive hierarchy". Renaming a job does not change its hierarchy information, so make sure the job has the correct name using all the private data and metadata available during the execution of the flow before it hits "Archive hierarchy".
The hierarchy works as intended with each job ending up in their correct directory. It is within the very bottom folder (Product Group) that I need the PNG files to be ordered by the Private Data but then renamed while retaining the ordering.
freddyp
Advanced member
Posts: 1130
Joined: Thu Feb 09, 2012 3:53 pm

Re: Order then Rename Jobs

Post by freddyp »

I need the PNG files to be ordered by the Private Data but then renamed while retaining the ordering.
I am not sure how to interpret this. "renamed while retaining the ordering" suggests that you want to rename the files, but that you do not want the rename to impact the ordering. What is the context of the ordering? In Finder/Explorer files are ordered by name, size, date, but not by private data. The only way to achieve that would be to rename the files using that private data. You seem to want to do this, but I have the impression that you consider the renaming and the ordering as two separate things.
Tenzo
Member
Posts: 22
Joined: Wed Jan 31, 2024 11:22 am
Location: USA :(
Contact:

Re: Order then Rename Jobs

Post by Tenzo »

freddyp wrote: Wed Dec 04, 2024 11:13 am I am not sure how to interpret this.
Here is an example:
Named by Private Data then Renamed to strip some information but retaining the order of the private data.

Batch_Rush_ProductGroup_Sku_UID_QTY ---> Renamed to ---> Batch_ProductGroup_Numerical Order_UID
  • B1_1_1HANDLE_WOODMOUNT9_2762543_001.PNG ------> B1_1HANDLE_001_2762543.png
  • B1_1_1HANDLE_WOODMOUNT9_2762543_002.PNG ------> B1_1HANDLE_002_2762543.png
  • B1_1_1HANDLE_WOODMOUNT14_2762629_001.PNG ------> B1_1HANDLE_003_2762629.png
  • B1_0_1HANDLE_WOODMOUNT18_2762211_001.PNG ------> B1_1HANDLE_004_2762211.png
  • B1_0_1HANDLE_WOODMOUNT23_2762388_001.PNG ------> B1_1HANDLE_005_2762388.png
Sorry, I am not the best and explaining things. Hopefully this visual can clear up any confusion.
freddyp
Advanced member
Posts: 1130
Joined: Thu Feb 09, 2012 3:53 pm

Re: Order then Rename Jobs

Post by freddyp »

Given
B1_1_1HANDLE_WOODMOUNT9_2762543_001.PNG
if B1, 1, HANDLE, WOODMOUNT9, 2762543, 001 are all available as private data keys you can just use "Rename job - Action 1 - Replace" and in the single-line text with variables concatenate them in a different order.

Should that not be the case you can create private data of the pieces of that file name separated by underscores using the StringSplitter app (https://www.enfocus.com/en/appstore/pro ... ngsplitter) and you can then do the renaming as described above.
User avatar
tdeschampsBluewest
Member
Posts: 132
Joined: Tue Jun 01, 2021 11:57 am

Re: Order then Rename Jobs

Post by tdeschampsBluewest »

Hi Tenzo,
If you are able at some point to group all the PNG (already renamed, without this order ID), using group jobs default app, you'll then be able to use "sort file in job" to add a prefix.

The rest of the flow is pretty straightforward : ungroup the job, retrieve the prefix with [Job.NameProper:Before="_"] and place it wherever you want it to be.
Do you like the Enfocus Apps developed by Bluewest?
Feel free to leave a comment on the Appstore!
Post Reply