hosyn Posted September 13, 2021 Share Posted September 13, 2021 (edited) Hi guys i gonna move some pdf files from current folder to selected folder something like that :: (vl-file-rename c://hh.pdf d://temp//hh.pdf) and our requst that for all files *.pdf move from c:/ to d:/tmp/*.pdf (vl-file-rename c://*.pdf d://temp//*.pdf) Edited September 13, 2021 by hosyn Quote Link to comment Share on other sites More sharing options...
mhupp Posted September 13, 2021 Share Posted September 13, 2021 (edited) (defun C:PDF-MOVE-ALL (/ lst fn fp) (setq lst (vl-directory-files "C:\\" "*.pdf" 1)) (foreach file lst (setq FN (strcat "C:\\" file)) (setq FP (strcat "D:\\temp\\" file)) (vl-mkdir "D:\\temp") (cond ((findfile FP) (setq reply (ACET-UI-MESSAGE (strcat "\nDo you want to Update " file) "Existing PDF" (+ Acet:YESNO Acet:ICONWARNING))) (if (= reply 6) ;Yes (progn (vl-file-delete FP) (vl-file-rename FN FP) (prompt (strcat "\n" FP " Updated")) ) ) ) ((not (findfile FP)) (vl-file-rename FN FP) ) ) ) (prompt (strcat "\n(" (itoa (length lst)) ") PDF Files moved")) (princ) ) Edited September 13, 2021 by mhupp always forget princ Quote Link to comment Share on other sites More sharing options...
hosyn Posted September 13, 2021 Author Share Posted September 13, 2021 (edited) 1 hour ago, mhupp said: (defun C:PDF-MOVE-ALL (/ lst) (setq lst (vl-directory-files "C:\\" "*.pdf" 1)) (foreach file lst (cond ((setq TXT (findfile (strcat "D:\\temp\\" file))) (setq reply (ACET-UI-MESSAGE (strcat "\nDo you want to Update PDF?") "Existing PDF" (+ Acet:YESNO Acet:ICONWARNING))) (if (= reply 6) ;Yes (progn (vl-file-delete (strcat "D:\\temp\\" file)) (vl-file-rename (strcat "C:\\" file) (strcat "D:\\temp\\" file)) ) ) ) ((not (setq TXT (findfile (strcat "D:\\temp\\" file)))) (vl-file-rename (strcat "C:\\" file) (strcat "D:\\temp\\" file)) ) ) ) (princ) ) Dear mhupp the code checked but didnt do well for me Edited September 13, 2021 by hosyn Quote Link to comment Share on other sites More sharing options...
mhupp Posted September 13, 2021 Share Posted September 13, 2021 (edited) I'v updated it already. only looks a C:\ no subflders will make D:\Temp if it doesn't exist. Edited September 13, 2021 by mhupp Quote Link to comment Share on other sites More sharing options...
lido Posted September 13, 2021 Share Posted September 13, 2021 You may use dos_move function from DOSlib. Quote Link to comment Share on other sites More sharing options...
hosyn Posted September 14, 2021 Author Share Posted September 14, 2021 thank you so much lido for new Quote Link to comment Share on other sites More sharing options...
hosyn Posted September 14, 2021 Author Share Posted September 14, 2021 (edited) 5 hours ago, mhupp said: I'v updated it already. only looks a C:\ no subflders will make D:\Temp if it doesn't exist. thank you mhupp all thing went well untill i try to make and change codes for asking user to make folder as : (defun C:mopdf1 (/ lst) (setq namfolder (strcat (getvar "DWGPREFIX") "pdf_" (getstring T "name of pdf folder :") "\\")) (vl-mkdir namfolder) (setq lst (vl-directory-files (getvar "dwgprefix") "*.pdf" 1)) (foreach file lst (cond ((setq TXT (findfile (strcat (getvar "dwgprefix") file))) (progn (vl-file-rename (strcat (getvar "dwgprefix") file) namfolder) (vl-file-delete (strcat (getvar "dwgprefix") file)) ) ) ) ( (vl-file-rename (strcat (getvar "dwgprefix") file) namfolder) ) ) ) (princ) ) (C:mopdf1) could you correct me in modified code?? Edited September 14, 2021 by hosyn for more explanation Quote Link to comment Share on other sites More sharing options...
mhupp Posted September 14, 2021 Share Posted September 14, 2021 57 minutes ago, hosyn said: could you correct me in modified code?? Are you wanting for the user to select locations? This will let you select 2 locations a source folder (where the pdfs are) and a destination folder (where you want to move them to). (defun C:PDF-MOVE-ALL (/ path path2 FP FP2 lst FS FD) (setq path (strcat (getvar 'DWGPREFIX) "\Move From Location") ;set source folder I don't like to use this because FP (getfiled "Navagate to Folder: " path "" 33) ;it shows up in quick access in windows explorer path (vl-filename-directory FP) ;just get the folder path lst (vl-directory-files path "*.pdf" 1) ;list all pdf in folder path ) (setq path2 (strcat (getvar 'DWGPREFIX) "\Move To Location") ;set destination folder I don't like to use this because FP2 (getfiled "Navagate to Folder: " path2 "" 33) ;it shows up in quick access in windows explorer path2 (vl-filename-directory fp2) ;just get the folder path ) (foreach file lst (setq FS (strcat Path "\\" file)) (setq FD (strcat Path2 "\\" file)) (cond ((findfile FD) (setq reply (ACET-UI-MESSAGE (strcat "\nDo you want to Update " file) "Existing PDF" (+ Acet:YESNO Acet:ICONWARNING))) (if (= reply 6) ;Yes (progn (vl-file-delete FD) (vl-file-rename FS FD) (prompt (strcat "\n" FD " Updated")) ) ) ) ((not (findfile FD)) (vl-file-rename FS FD) ) ) ) (prompt (strcat "\n(" (itoa (length lst)) ") PDF Files moved")) (princ) ) Cant use vl-mkdir because you can't set path2 without selecting a folder from getfiled. Quote Link to comment Share on other sites More sharing options...
hosyn Posted September 14, 2021 Author Share Posted September 14, 2021 Dear Mhupp So Appriciate your attempt to helping. The dialog define sourse folder and nav is opened but not allow assign correctly the path, is it maybe should change some of variable?!?!? Quote Link to comment Share on other sites More sharing options...
mhupp Posted September 14, 2021 Share Posted September 14, 2021 1 hour ago, hosyn said: Dear Mhupp So Appriciate your attempt to helping. The dialog define sourse folder and nav is opened but not allow assign correctly the path, is it maybe should change some of variable?!?!? Are you hitting the save button? Quote Link to comment Share on other sites More sharing options...
hosyn Posted September 15, 2021 Author Share Posted September 15, 2021 23 hours ago, mhupp said: Are you hitting the save button? that way was complicated to select origin and destination with that dialog box,, one time it does well moving but moving all type files instead pdf files and for so many times had difficulity to do. its neat be if can making simplify the code that: 1-after running the code asked for the name to make folder with that name in current path 2-move the pdf files from current path to new folder aleady made . No need to open dialog box ,and moving pdf files from current path to new folder (getstring " type for the name new folder for pdf files") Quote Link to comment Share on other sites More sharing options...
mhupp Posted September 15, 2021 Share Posted September 15, 2021 (edited) Will ask for a folder name and create it in the current drawings folder. then move all PDF's from the current drawing folder to new folder. and give an update on how many files where moved. "3 PDF Files moved" (defun C:PDF-MOVE-ALL (/ path path2 lst FP FS FD c) (setq path (getvar 'DWGPREFIX) lst (vl-directory-files path "*.pdf" 1) FP (getstring T "\nENTER PDF FOLDER NAME: ") c 0 ) (vl-mkdir (setq path2 (strcat path "//" FP))) (foreach file lst (setq FS (strcat Path "\\" file)) (setq FD (strcat Path2 "\\" file)) (cond ((findfile FD) (setq reply (ACET-UI-MESSAGE (strcat "\nDo you want to Update " file) "Existing PDF" (+ Acet:YESNO Acet:ICONWARNING))) (if (= reply 6) ;Yes (progn (vl-file-delete FD) (vl-file-rename FS FD) (prompt (strcat "\n" FD " Updated")) (setq c (1+ c)) ) ) ) ((not (findfile FD)) (vl-file-rename FS FD) (setq c (1+ c)) ) ) ) (prompt (strcat "\n" (itoa c) " PDF Files moved")) (princ) ) Edited September 16, 2021 by mhupp (getstring T "\nprompt:") allows for spaces in folder name Quote Link to comment Share on other sites More sharing options...
hosyn Posted September 16, 2021 Author Share Posted September 16, 2021 (edited) DEAR mhupp I don no how can say the words to appreciate you deeply , if we wanna zip those pdf and email them which commands we must added in the bottom of codes indeed as soon as moving to folder making rar file of them( if its npossible, i dont know) and the second step email them( if its possible, i dont know) Edited September 16, 2021 by hosyn Quote Link to comment Share on other sites More sharing options...
BIGAL Posted September 16, 2021 Share Posted September 16, 2021 (edited) You can manually make a zip without using explorer like wise can unzip a file to a directory, just google ZIP Hint How to automatically zip files with a batch file. Extra hint use (command "shell" mybatfile) Edited September 16, 2021 by BIGAL Quote Link to comment Share on other sites More sharing options...
mhupp Posted September 16, 2021 Share Posted September 16, 2021 @ronjonp has a good email lisp. 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.