J-LYLE Posted March 19, 2008 Share Posted March 19, 2008 Im wanting to be able to copy a file from a known location to the directory of the file i have open is in(will not always be the same), but im not sure where to start. Any advice? Thanks. Quote Link to comment Share on other sites More sharing options...
J-LYLE Posted March 19, 2008 Author Share Posted March 19, 2008 In case i phrased the question very poorly. I want to copy 1.dwg from..Ex: C:\ACAD\1.dwg to the directory that the file i have open is in. (..\Refs). I would be thankfull for any sugestions. Quote Link to comment Share on other sites More sharing options...
lpseifert Posted March 19, 2008 Share Posted March 19, 2008 This may help, it will open Windows Explorer in the folder of the dwg you have open. (startapp "explorer" (strcat "/e,"(getvar "dwgprefix"))) Quote Link to comment Share on other sites More sharing options...
ASMI Posted March 19, 2008 Share Posted March 19, 2008 From Developer Help: vl-file-copy Copies or appends the contents of one file to another file (vl-file-copy source-file destination-file [append]) Copy or append the contents of one file to another file. The vl-file-copy function will not overwrite an existing file; it will only append to it. Arguments source-file A string naming the file to be copied. If you do not specify a full path name, vl-file-copy looks in the AutoCAD default drawing directory. destination-file A string naming the destination file. If you do not specify a path name, vl-file-copy writes to the AutoCAD default drawing directory. append If specified and not nil, source-file is appended to destination-file (that is, copied to the end of the destination file). Return Values An integer, if the copy was successful; otherwise nil. Some typical reasons for returning nil are source-file is not readable source-file is a directory append? is absent or nil and destination-file exists destination-file cannot be opened for output (that is, it is an illegal file name or a write-protected file) source-file is the same as destination-file Examples Copy autoexec.bat to newauto.bat: _$ (vl-file-copy "c:/autoexec.bat" "c:/newauto.bat") 1417 Copy test.bat to newauto.bat: _$ (vl-file-copy "c:/test.bat" "c:/newauto.bat") nil The copy fails because newauto.bat already exists, and the append argument was not specified. Repeat the previous command, but specify append: _$ (vl-file-copy "c:/test.bat" "c:/newauto.bat" T) 185 The copy is successful because T was specified for the append argument. Quote Link to comment Share on other sites More sharing options...
J-LYLE Posted March 20, 2008 Author Share Posted March 20, 2008 Maby I missunderstood, what I thought would happen is that when I ran the lisp it would copy the file "W0114-150.dwg" into the directory of the drawing I had open at the time, but unfortunatly it did nothing. Can anyone please offer some advice on "vl-file-copy". (vl-file-copy "C:/ACAD/Lisp/testLISPFORNEWWDSPULLDOWN/W0114-150.dwg" "" T) Quote Link to comment Share on other sites More sharing options...
hendie Posted March 20, 2008 Share Posted March 20, 2008 you've only provided one file name. It's looking for a source file AND a destination file oops, you did provide two but the second one is "" Quote Link to comment Share on other sites More sharing options...
J-LYLE Posted March 20, 2008 Author Share Posted March 20, 2008 Thanks for the quick reply. What I was shooting for was not to have to give it a destination I want the file name to be the same and the destination to be what ever directory the open drawing im working in is in. Is that possiable with this function or should I try to figure it out another way.? Quote Link to comment Share on other sites More sharing options...
dbroada Posted March 20, 2008 Share Posted March 20, 2008 so you are working on myFolder\Drawing1.dwg and you want to have a copy of networkFolder\refDrawing.dwg saved as myFolder\refDrawing.dwg? Quote Link to comment Share on other sites More sharing options...
J-LYLE Posted March 20, 2008 Author Share Posted March 20, 2008 For Ex: I will be working on h:\00001\drawing1.dwg or h:\00002\drawing1.dwg or h:\00003\drawing1.dwg...ect... and want to copy c:\drawingZ.dwg to h:\00001\drawingZ.dwg or h:\00002\drawingZ.dwg...ect.... The destination will change depending on what job/file I am working on. My plan is that after I figure out how to copy the file this way to also have this file xrefed in to the file I am working on to add certain details for specific conditions on jobs. The xref needs to be in the job folder and xrefed from their incase of special changes specific to that job, but I only want to add it to the job if I need it. Quote Link to comment Share on other sites More sharing options...
wizman Posted March 20, 2008 Share Posted March 20, 2008 give this a try j-lyle, (defun c:test (/ curr_dir foldr&flname_2copy) (vl-load-com) (setq foldr&flname_2copy '("C:\\Documents and Settings\\wizman\\My Documents\\" [color="blue"];<<< input here folder path of source[/color] "Drawing1.dwg" [color="Blue"];<<< input here filename to be copied[/color] ) ) ;_ end_setq (if (findfile (apply 'strcat foldr&flname_2copy)) (if (findfile (strcat (getvar "dwgprefix") (cadr foldr&flname_2copy))) (alert "\n File Exists in Destination Folder") (progn (setq curr_dir (strcat (getvar "dwgprefix") (cadr foldr&flname_2copy))) (vl-file-copy (apply 'strcat foldr&flname_2copy) curr_dir) (prompt (strcat (strcase (cadr foldr&flname_2copy)) " copied to " (strcase (getvar "dwgprefix")) ) ;_ end_strcat ) ;_ end_prompt ) ;_ end_progn ) ;_ end_if (alert "\n Source File Does not Exist") ) ;_ end_if (princ) ) ;_ end_defun (princ) Quote Link to comment Share on other sites More sharing options...
J-LYLE Posted March 21, 2008 Author Share Posted March 21, 2008 Thanks for the reply, Hopefully I will have some time to give it a try latter on today. This will help alot. Quote Link to comment Share on other sites More sharing options...
J-LYLE Posted March 24, 2008 Author Share Posted March 24, 2008 Worked great! Thanks for the much needed help. Quote Link to comment Share on other sites More sharing options...
bobafuka Posted August 21, 2008 Share Posted August 21, 2008 (setq curdir (getvar "dwgprefix")) (vl-file-copy "path and file.ext in here" curdir ) Quote Link to comment Share on other sites More sharing options...
hailualua Posted November 16, 2018 Share Posted November 16, 2018 (setq foldr&flname_2copy '("C:\\Documents and Settings\\wizman\\My Documents\\" [color="blue"];<<< input here folder path of source[/color] "Drawing1.dwg" SOrry!! Help me!!!! I want file name is input from editbox!!! thanks!!! Quote Link to comment Share on other sites More sharing options...
hailualua Posted November 16, 2018 Share Posted November 16, 2018 On 3/21/2008 at 4:21 AM, wizman said: give this a try j-lyle, (defun c:test (/ curr_dir foldr&flname_2copy) (vl-load-com) (setq foldr&flname_2copy '("C:\\Documents and Settings\\wizman\\My Documents\\" [color="blue"];<<< input here folder path of source[/color] "Drawing1.dwg" [color="Blue"];<<< input here filename to be copied[/color] ) ) ;_ end_setq (if (findfile (apply 'strcat foldr&flname_2copy)) (if (findfile (strcat (getvar "dwgprefix") (cadr foldr&flname_2copy))) (alert "\n File Exists in Destination Folder") (progn (setq curr_dir (strcat (getvar "dwgprefix") (cadr foldr&flname_2copy))) (vl-file-copy (apply 'strcat foldr&flname_2copy) curr_dir) (prompt (strcat (strcase (cadr foldr&flname_2copy)) " copied to " (strcase (getvar "dwgprefix")) ) ;_ end_strcat ) ;_ end_prompt ) ;_ end_progn ) ;_ end_if (alert "\n Source File Does not Exist") ) ;_ end_if (princ) ) ;_ end_defun (princ) SOrry!! Help me!!!! I want file name is input from editbox!!! thanks!!! Quote Link to comment Share on other sites More sharing options...
BIGAL Posted November 16, 2018 Share Posted November 16, 2018 Just look at the previous posts (vl-file-copy "c:/autoexec.bat" "c:/newauto.bat") or (vl-file-copy File1 file2) where file1&2 are lisp variables Quote Link to comment Share on other sites More sharing options...
hanhphuc Posted November 16, 2018 Share Posted November 16, 2018 19 hours ago, hailualua said: I want file name is input from editbox!!! thanks!!! Cheating acaddoc.. (setq fn (lisped "ABC.dwg"))[/Code] 1 Quote Link to comment Share on other sites More sharing options...
rcb007 Posted February 23, 2022 Share Posted February 23, 2022 I know this is an old topic. How could I change this from a file to a folder with everything in it? I thought i would swap out the file name and extension to a (* *), but not so much. Thank you for any pointers. (defun c:test (/ curr_dir foldr&flname_2copy) ;;https://www.cadtutor.net/forum/topic/1138-copy-file-to-current-directory/ (vl-load-com) (setq foldr&flname_2copy '("C:\\Documents and Settings\\wizman\\My Documents\\" ;;[color="blue"];<<< input here folder path of source[/color] ;; "Drawing1.dwg" ;;[color="Blue"];<<< input here filename to be copied[/color] "*.*" ;;assuming for all folders and files ) ) ;_ end_setq (if (findfile (apply 'strcat foldr&flname_2copy)) (if (findfile (strcat (getvar "dwgprefix") (cadr foldr&flname_2copy))) (alert "\n Folder and Files Exist in Destination Folder") (progn (setq curr_dir (strcat (getvar "dwgprefix") (cadr foldr&flname_2copy))) (vl-file-copy (apply 'strcat foldr&flname_2copy) curr_dir) (prompt (strcat (strcase (cadr foldr&flname_2copy)) " copied to " (strcase (getvar "dwgprefix")) ) ;_ end_strcat ) ;_ end_prompt ) ;_ end_progn ) ;_ end_if (alert "\n Source Folder and Files Do not Exist") ) ;_ end_if (princ) ) ;_ end_defun (princ) Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 24, 2022 Share Posted February 24, 2022 (edited) Ok the answer is old fashioned DOS XCOPY, you can run windows CMD using (command "shell" "xcopydoscommand") so google xcopy as 1st step. Edited February 24, 2022 by BIGAL Quote Link to comment Share on other sites More sharing options...
rcb007 Posted February 24, 2022 Share Posted February 24, 2022 Thanks! I think i can go from there. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.