Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Change the filenames of 330 files based on a certain ID in cell

Mikkel94
7 - Meteor

Hi all,

 

I have 330 identical files and I need to change their name based on the info in a certain cell (the location of the cell is always the same in all 330 files).

Attached you find a example excel where the yellow marked cell needs to be target for the filename changing.

I hope you can help me! 🙂

 

Kind regards,

 

Mikkel

8 REPLIES 8
JoeS
Alteryx
Alteryx

Hi @Mikkel94 

 

Are these files all stored in the same folder?

 

What I think you'd want to do is use a directory tool to read in all the sheets, then write out a batch file and run that to do the rename.

 

If you let me know the input structure of your folders, I can build a mock up workflow.

LukeG
Alteryx Alumni (Retired)

Hey @Mikkel94 

 

I put together a workflow that should demonstrate how you can output multiple files based on criteria. I used your example file as well as a similar one I created.

 

I used two input tools and a union. However, I recommend using a wildcard character in the input tool to bring in multiple files at once. (I did this so I could package the data with the workflow.)

 

Pay close attention to the configuration of the output tool (specifically the bottom part of it). This configuration allows you to write multiple output files by grouping o a specific field. In this case, the FileName.

 

Output Multiple Files.png

 

Let me know if there are any other questions !

 

Luke

JoeS
Alteryx
Alteryx

I have attached the flow that I explain above.

 

Workflow.png

 

Please note that Alteryx will only read the data cell that has the name in, and no others. It will then use windows to rename the file. So all formatting of the workbook will be retained.

patrick_digan
17 - Castor
17 - Castor

@Mikkel94 

 

@LukeG solution is very good and straightforward in simple cases. If you needed to keep the original formatting or other complex situations, @JoeS method of bat commands would be the standard way to go; however, @JosephSerpis had an interesting post about using blobs that would seem to work as well. I've modified @LukeG perfectly working solution to demonstrate the blob method which will maintain formatting.

 

Really I just thought @JosephSerpis blog was awesome and it would possibly solve your use case.

 

 

Vicks
5 - Atom

An iterative macro is created. Macro screenshot is attached. Let me know if this helps you meet your objective.

hockett86
5 - Atom

EDIT: Point number 2 below: My error was just that the Run Command wasn't saving or running from the correct place. Adding ".\" prior to the file name/location allowed it to operate in the same folder location

 

@JoeS, I have a few questions on your workflow.

 

1. The Dynamic Input tool also requires a path: Should I assume that this path is the same as given in the Directory tool? You didn't mark it with a red comment, so I wanted to be sure

2. I'm having issues with the RunFile.bat: namely, I don't think there is any file to run. Did you forget to include the .bat in your upload?

JoeS
Alteryx
Alteryx

Hi @hockett86 

 

Sorry about the slow response to your questions.

 

1. The dynamic input tool receives the full path from the workflow steps before it. So shouldn't need updating.

2. If you have updated the path and no .bat file is being produced the something must be going wrong in the previous steps. There is no .bat file to upload as the workflow itself creates that file and outputs it using the Run Command tool.

Are you able to provide screenshots of how it looks along the way, I can then look to help debug.

hockett86
5 - Atom

@joeS

 

I got it all squared away. Sorry for the trouble.

Labels