Alteryx Designer Desktop Discussions

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

Copy and Rename File with Command Prompt

pcatterson
11 - Bolide

I am using the Run Command tool to copy and rename files.

 

I want the command

 

 

copy C:\\StartFolder\Input.txt C:\\FinalFolder\Output.txt

 

 

to copy the contents of the first file into the new file and location.

 

but instead, it keeps the same file name and treats the file is another directory to create:

 

C:\\FinalFolder\Output.txt\Input.txt

 

Any work around or fix to my syntax?

3 REPLIES 3
RolandSchubert
16 - Nebula
16 - Nebula

Hi @pcatterson ,

 

you could try

copy C:\StartFolder\Input.txt C:\FinalFolder

 

I think, if the filename is not changed, you only need the destination folder.

 

Best,

 

Roland

 

 

pcatterson
11 - Bolide

Yes, leaving the name unchanged works

 

But I need to rename the file.  Can I do this in one step or should I do it multiple steps?

Vijuzy
8 - Asteroid

I use this python code to copy/rename files from Alteryx. Just pass original file address in 'FileName' field and new file address in 'NewFileName' field.

 

from ayx import Alteryx
import shutil, os
df = Alteryx.read("#1")
sfile = df.at[0,"FileName"]
nFile= df.at[0,"NewFileName"]
nFile = folder + nFile
shutil.copy(sfile, nFile)
Alteryx.write(df,1)

 

Regards,

 

Vijay

Polls
We’re dying to get your help in determining what the new profile picture frame should be this Halloween. Cast your vote and help us haunt the Community with the best spooky character.
Don’t ghost us—pick your favorite now!
Labels