Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Select 2 most recent files for ID in a folder and then copy the files to a new folder

guido_vianson
5 - Atom

Hello,

 

i need to collect the files that I am receiving in a folder called 'Replies'. I have 3 type of possible files:

AIFFBR

AIFFDB

AIFFBH

 

These are submission receipts. This means that I am always getting AIFFBR% file, same for AIFFDB%. Then, if AIFFDB% is fine, I am also getting a AIFFBH% as confirmation.

They are .zip and .txt extension with same naming convention. I only need the .zip files and not the .txt.

 

I seek for a specific file by filtering on the ID contained in the File Name and on the Creation Time column.

AIFFDB-100000000-A00001600-V00002700-00000000-AIF-20240126165425_20240129113335675.zip

 

AIFFBH-100000000-A00002000-V00006400-00000000-AIF-20240127042128_20240129103427384.zip

 

This is the file naming convention.

Most recent is based on the column of the folder 'Creation Time'

 

 

 

If I am filtering for V000001-0000000 and a specific date range I might get multiple files.

This depends on how many times the submission was done. 

I only want to select the most recent AIFFDB and AIFFBH files for each ID I am looking for.

 

The result should then be copied to a new folder in the download folder.

 

can you please help me to build the same?

 

So far I am importing to Alteryx using a Directory.

Then I am filtering using 'contains' in File Name but I need to find a better way as I might need to search 40 different ID.

 

The challenge is how to select the 2 most recent file for ID and then copy the same to a new folder?

I tried to understand how to use a CMD but not very clear for me.

 

Thank for your help

 

 

 

9 REPLIES 9
ChrisTX
15 - Aurora

Can you post a sample of actual file names in table format or text format in this forum?

 

When you said "I only want to select the most recent AIFFDB and AIFFBH files"

 

Is "the most recent" determined by file creation date?

 

Chris

guido_vianson
5 - Atom

AIFFDB-100000000-A00001600-V00002700-00000000-AIF-20240126165425_20240129113335675.zip

 

AIFFBH-100000000-A00002000-V00006400-00000000-AIF-20240127042128_20240129103427384.zip

 

This is the file naming convention.

Most recent is based on the column of the folder 'Creation Time'

 

 

alexnajm
16 - Nebula
16 - Nebula

If you have the Directory tool already, it’ll be a matter of parsing out the relevant information from the file name to give yourself a column with each “group”, sorting the data on Creation Date like @ChrisTX is mentioning, and Sampling the First N Records with N=1 and grouping by that group!

ChrisTX
15 - Aurora

See if the attached workflow points you in the right direction

 

Screenshot 2024-01-29 055810.png

Chris

alexnajm
16 - Nebula
16 - Nebula

Nice @ChrisTX !

guido_vianson
5 - Atom

@ChrisTX yes it helped thanks!!. I changed some fields and added a formula to concatenate 2 fields. 

 

Do you also know how to copy the result in a new folder?

ChrisTX
15 - Aurora

I don't understand the question "how to copy the result in a new folder"

 

Do you want to create a new folder then save an output file in that folder?

What's an example format for the new folder name.

 

To create a folder: you will likely need to create and run a BAT file using the Run Command tool under the Developer category.

 

Chris

guido_vianson
5 - Atom

Yes exactly. I would like the files to be copied to a a new folder (no name convention needed) in the Downloads folder

Labels