Alteryx Designer Desktop Discussions

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

Renaming hundreds of image names with proper sorting

knozawa
11 - Bolide

I would like to rename each image with 10 digits of numbers. 

 

For example:

Screenshot 2016-11-06 11.05.10.png

For those images, I would like to rename as: 0000000001.png,0000000002.png, and 0000000003.png. 

This is the reference for coding: http://askubuntu.com/questions/473236/renaming-hundreds-of-files-at-once-for-proper-sorting.

 

I am wondering if I can use Alteryx to rename those images. 

 

Sincerely,

Kazumi

7 REPLIES 7
Joe_Mako
12 - Quasar

In the attached workflow, it uses a Directory toll to get the contents of a folder, then a formula tool to generate the new file name, and construct the command:

 

New FileName:

PadLeft([FileName], 14, "0")

 

Code:

'ren "'+[Directory]+[FileName]+'" "'+[New FileName]+'"
echo '+[FileName]+','+[New FileName]

 

it then unions the text "echo off" to be the first record, Selects on the Code field, uses the Run Command tool to execute the generated commands, reads back in the list of name changes.

 

rename.png

knozawa
11 - Bolide

Hi @Joe_Mako,

 

It worked! Thank you!

 

I have a follow-up question:

I have an excel file which includes bulk of unique IDs (over 97,000 unique IDs).

Since those unique IDs do not have matched images, I would like to connect these unique IDs with "No Image Available" image below:

NO Image Available.jpg 

The disired result would be like this:

Screenshot 2016-11-17 23.36.33.png

Do you think there is a way to do this using Alteryx?

 

Thank you,

Kazumi

Joe_Mako
12 - Quasar

If your "No image" image is called 0.jpg and is in the same directory as all the other images (with filename 1.jpg, 2.jpg, 3.jpg), and you have tour data source will a list of expected IDs:

 

0000000001
0000000002
0000000003
0000000004
0000000005
0000000006

 

then the attached workflow will rename the three known files, and copy/rename 0.jpg into the other three expected filenames.

 

rename v2.png

 

knozawa
11 - Bolide

Hi @Joe_Mako,

 

Thank you for your reply.

 

Unfortunately, I got no response when I used your workflow.  It says that the system cannot find the file specified.

renamev2.png

 

When I used my excel file that includes 97,000 unique IDs, I got another error, "The external program 'rename.bat' returned an error code: 1.

renamev2.2.png

 

Do you know what's happening in this workflow?

 

Sincerely,

Kazumi

knozawa
11 - Bolide

After running the workflow, I have 96,987 JPEG images in the folder.  However, there are only 96,958 unique IDs in the excel file. 

I checked if there are duplicated images, but there was no duplication. Are there any ways to check which JPEG images (29 images) are not linked to the unique IDs in the excel file?

 

Thank you,

Kazumi

Joe_Mako
12 - Quasar

My guess is those 29 records would come out of the Left output of the Join tool.

knozawa
11 - Bolide

Hi @Joe_Mako,

 

Thank you, @Joe_Mako.  There were 17 images from Left output of the join tool.  I could see some of the names did not match due to the different image format (.png vs .jpg).  I deleted duplicated images (.png vs .jpg) and I have 96,976 images now.  There still have 18 unmatched images, but I will try to figure it out.

 

Sincerely,

Kazumi

Labels