Copy File from One Folder to Another and Rename it dynamically
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi team,
I have a master template (.xlsx file with multiple tabs). I do not want the master template to be touched.
I want Alteryx to copy the file into a specific location and rename it. Is it possible?
I would then use this file to fill specific ranges using Alteryx workflow.
Thanks in Advance.
Solved! Go to Solution.
- Labels:
- Common Use Cases
- Python
- Run Command
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
You have a few different options depending on how complex your template is. If it's a small number of tabs and you intend to write to most of them you can just read in the template and write output to the new location. This may be a use case for an app if you want to be able to specify the output location or some form of config file if you want to be store the output location somewhere independent of workflow execution.
If you need to copy a template that is large and particularly one that has a lot of stuff that you aren't processing in the workflow, that might be a job for a run command, which can do anything you could do with a command line batch file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
In response to the first part of your question.... copy and move...
You can use the Run Command tool to move/change file names.
Two main things:
1. Create a field with the command you want the Run Command tool to use (CMD in the example below). The key is the REN command at the start of the expression you create. Use your workflow to work any changes you want in the field name, etc. See first image below.
2. Configure the Run Command tool itself as depicted in the second image below.
In my case, I wanted to edit the names of a few hundred files. I placed copies of the files I wanted to edit in a target folder and then used the workflow to edit the file names using the "CMD" expression I created (image #1) and then pass the CMD field (and only the CMD field) to the Run Command tool.
There's nothing to suggest you could not configure your CMD expression to save to a different file location as well as rename it.
But, even this example Alteryx is touching the file. So, why can't you input the original, perform your changes, and then output the edited file to the new target folder?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Here is a little more detail regarding the CMD expression. The REN command takes two inputs:
1. The new file path (i.e., where you want to move it) with the new file name.
2. The new file name.
The construct looks like this:
REN "Drive:\NewfilePath\NewFileName.pdf" "NewFileName.pdf"
So, a close a close to real world example might look like this:
REN "D:\Users\YourName\NAS\2021\Working\Binders\Production\2021-YADA-YADA-YADA.pdf" "2021-YADA-YADA-YADA.pdf"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @hellyars
I cannot input the original template because I will lose the formatting present on it.
Hence, I am trying to move it to a new location and then only update specific portions of the file using write to a range without compromising on the formatting.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
