copy file from one directory to another

copy file from one directory to another

greg_xpp
Contributor Contributor
729 Views
6 Replies
Message 1 of 7

copy file from one directory to another

greg_xpp
Contributor
Contributor

What is the command to copy a file from one directory to another?for example, to open files we use 'OLE FILEACTION 'open'.

is it possible to copy via OLE command?

0 Likes
730 Views
6 Replies
Replies (6)
Message 2 of 7

ondrej.mikulec
Advocate
Advocate
STRING sourceFilepath = "C:\Users\powermill\Documents\cube.dmt"
STRING targetFilepath = "C:\Users\powermill\Documents\cube2.dmt"
STRING batFilePath = "C:\Users\powermill\Documents\copy.bat"

FILE OPEN $batFilePath FOR WRITE AS output

STRING textLine1 = "@echo off"
STRING textLine2 = "set source=" + $sourceFilepath
STRING textLine3 = "set destination=" + $targetFilepath
STRING textLine4 = ""
STRING textLine5 = 'copy "%source%" "%destination%"'

FILE WRITE $textLine1 TO output
FILE WRITE $textLine2 TO output
FILE WRITE $textLine3 TO output
FILE WRITE $textLine4 TO output
FILE WRITE $textLine5 TO output

FILE CLOSE output

OLE FILEACTION 'open' $batFilePath
Message 3 of 7

nguyenthinhvt95
Advocate
Advocate

Hi @ondrej.mikulec,

Your macro is working nice for a file!

But I would ask how can we copy and past a folder to another directory.

 

0 Likes
Message 4 of 7

ondrej.mikulec
Advocate
Advocate

The macro simply involves creating and executing a batch file, which means you can accomplish most tasks that a batch file can handle. To determine the specific commands to include in the batch file, I suggest seeking assistance for example from ChatGPT.

0 Likes
Message 5 of 7

nguyenthinhvt95
Advocate
Advocate

@ondrej.mikulec :Thank you

0 Likes
Message 6 of 7

mayankpatel5523
Explorer
Explorer

Is this possible?IMG_20230630_190450.jpg

0 Likes
Message 7 of 7

Cobra.007
Enthusiast
Enthusiast

Yes that should be possible, but like this

 

STRING PATH2 = SUBSTRING($ModelName,0,100)

 

Greetings

0 Likes