Jump to content

help in moving files


hosyn

Recommended Posts

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 by hosyn
Link to comment
Share on other sites

  • hosyn changed the title to help in moving files
(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 by mhupp
always forget princ
Link to comment
Share on other sites

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 by hosyn
Link to comment
Share on other sites

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 by hosyn
for more explanation
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?!?!? 

Link to comment
Share on other sites

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?

 

 

Link to comment
Share on other sites

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")

 

Link to comment
Share on other sites

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 by mhupp
(getstring T "\nprompt:") allows for spaces in folder name
Link to comment
Share on other sites

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 by hosyn
Link to comment
Share on other sites

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 by BIGAL
Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...