Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

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

Capturing the Source File Name from a Macro Input

I would like to configure a macro to write the input file name into a field, capturing the file name from the macro input. I can't rely on the 'Output File Name as Field' option being used, since the file input is outside the scope of the macro. I was hoping there was some sort of function that would parse the source filename from a data stream, but have as yet been unable to find it.


Screen shot attached below, for general reference:






Hi Dan,


Is the input file outside the macro changing? If so the input file should automatically update the macro input and change the file name field if you choose the 'Output File Name as Field' option. I have tested this and it seems to work for me. 


Alternatively there is the field info tool within the developers tab which produces the source file you referenced below. You could then parse the file name using reg-ex or text to column tool from there. 




Jordan Barker

Client Service Representative 


Thanks, Jordan. That did it.


Since I couldn't guarantee the user would have the file name included in advance, I used the Field Info tool as you suggested. From there, I just had to select transpose the Field Info results, then parse the file name from the path. In order to get it back into the output file, I populated the desired _FileName field with "path", then used the Find and Replace tool to replace the word "path" in the _FileName field with the actual file name, from the reference table.




Excellent! Good work on the rest of the workflow!

Would you please kindly share the source code for this? I have been wanting to complete a similair task.

This was in the middle of a larger workflow, so beg your pardon if it behaves strangely.


All the parts are there, though, and the functionality should be pretty straightforward.

Alteryx Alumni (Retired)


Posted in error! 


Andy Cooper
Senior Solutions Engineer - EMEA


I have a simple macro that reads a folder that has 20+ .txt files with inconsistent schema. just an additional column in few files. So I have used this macro for a while to get this data in a common table. Now I require the file names for each record to be appended to extract some attribution information. when I try to add the filename feature in input tool set inside the macro, the output just appends the template name that's being pointed out rather than the actual file names. 


am trying to make use of your macro not am not able to utilize as am very new when it comes to macros. Can you breakdown your WF or give me push to accomplish my ask? 


looking forward. 


Hi @Raghu_s


Inside of your macro your input tool and interface designer (View>Interface Designer) need to look like this:




This will append the file name to each row in that txt file. Make sure you add a browse tool outside the macro to see all rows of data.




Jordan Barker