We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Copy files from 1 directory to another directory based on certain conditions

NISHA_373
7 - Meteor

I have files in one directory and based on target date, I want to replace those files present in another directory. Basically I want to update the latest file from 1st directory folder to another. I have designed all the logic, I am just not able to write the output in the second directory.

 
 

 

5 REPLIES 5
Sebastian_Chaieb2
11 - Bolide
11 - Bolide

Hi @NISHA_373 

 

You have two options here:

1. Read file from second folder using Dynamic Input and write it to the first folder using [FullPath] from the first Directory tool. Workflow will looks more or less like this:

pic1.png

Output tool and dynamic path:

pic2.png

 However this solution will works for one file at the time, if you need it for many files I will recommend to create a batch macro (one file per batch) 

 

2. Use Run command tool. I will prefer that solution as it dose not need to reed data, just to take one file and overwrite in second destination. 

Workflow will just need both full paths and command should like this "copy /y "C:\Temp\Folder1\Test.xlsx" "C:\Temp\Folder2\Test.xlsx" (where C:\Temp\Folder1\Test.xlsxis [FullPath] from one folder and C:\Temp\Folder2\Test.xlsx is the Destination folder + filename) 

Workflows should looks like this:

pic3.png

This solution also will works if you want to MOVE file not only copy

 

Hope that helps you :) 

Sebastian 

 

NISHA_373
7 - Meteor

File extension type is .cmd  and not .xlsx. That's where I am facing the main issue

NISHA_373
7 - Meteor

I am trying to use the Run Command tool but it's giving me error even though I have given the right path in my command.

Sebastian_Chaieb2
11 - Bolide
11 - Bolide

Please try attached solution.

I used same file in both location (so in the Join tool it is joined based on FullPath from both folders. So if the file name is the same it will be copy (in my example moved from folder 1 to folder 2. In the Run Command tool you can check how it is configured (in simple words, I am creating a cmd in Formula, it is outputted to temporary file %temp%\rmdir.bat (I should change the name but already attached :P) and in Command it is calling that temp file saved as BAT. 

 

In cmd (in formula I used "MOVE" instead of "Copy" to check if command is working) so you can change it again to COPY. 

 

If that solution works, please tag this response as SOLVED :)

Thanks,

Sebastian 

Sebastian_Chaieb2
11 - Bolide
11 - Bolide

Hi @NISHA_373 

Dose the solution works for you? If yes, please tag my response as Solved.

 

Thanks,

Sebastian 

Labels
Top Solution Authors