Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Macro to move file?

Hamder83
11 - Bolide

Hi

Anyone knows of a simple macro to move files? 

Ive tried googeling for a while now, but havnt faound anything I can make work.

I want to be able to use a directory input to get all files.
They contains which week they are created and a customer number.

From that info I want to move the files to the correct sub folder based on Customer number and week.

So: 
FileName: Dennis_Schlein (Customer) 270183 (ID) - Week 8.

Destination:
P:\Invoice\[Customer name]\Week 8\ 

Anyone who can assist with something like this? 


Kind regards

5 REPLIES 5
afv2688
16 - Nebula
16 - Nebula

Hello @Hamder83 ,

 

To move files you would need yo use the command tool. The best way to do it would be to create a batch macro with the following command

 

move "<origin>" "<destination>"

 

The quotes are important and useful just in case any path has some spaces (we would avoid that error this way).

 

Here is a macro that does it:

 

https://community.alteryx.com/t5/Alteryx-Designer-Discussions/Configure-Run-Command-tool-to-move-a-f...

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Regards

 

Hamder83
11 - Bolide

You are a god! 

That works like a charm 🙂 

Thank you very much 

afv2688
16 - Nebula
16 - Nebula

Glad you liked it.

 

You can also switch the command within to create folders, delete files etc.

 

Also don't know if you are aware but when moving the files you can also rename them at the same time:

 

move "C:\Users\IronMan\Documents\old_name.xlsx" "C:\Users\ESd01631\Documents\secrets\new_name.xlsx"

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Regards

Hamder83
11 - Bolide

Hi @afv2688 

 

One last question,i tried and change it to my own folder path.

 

But now i get a error message: code 1? 

Hamder83_0-1582632255182.png

 

afv2688
16 - Nebula
16 - Nebula

Hello @Hamder83,

 

The error code one can be related to many things. Most of the times is either given due a mistype, path not existing or a permission issue.

 

To check it out I would recommend you to try to run the command you are passing to your workflow directly into a cmd window. There you will be able to see what is really happening.

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Regards

Labels