bak文件闪电战
有没有简单的路由方式。将文件备份到特定的文件夹?他们把我的文件弄乱了。:气死了:还是有更好的办法对付他们?谢谢!
**** Hidden Message ***** 我们有一个网络清除器,每天晚上把它们从网络上删除。 如果你根本不使用它们,你可以阻止它们被制作。它们不止一次救了我的命,所以我只是偶尔在心情不好的时候删除它们。 您可以在启动中添加以下内容:
(defun _movebak (folder / dest dir files)
(if (and (vl-file-directory-p folder)
(setq dir (getvar 'dwgprefix))
(setq files (vl-directory-files dir "*.bak" 1))
)
(foreach f files
(vl-catch-all-apply 'vl-file-copy (list (strcat dir f) (strcat folder f)))
(vl-catch-all-apply 'vl-file-delete (list (strcat dir f)))
)
)
(princ)
)
(_movebak "C:\\myfolder\\")
或(setvar'isavebak 0),以阻止创建它们。 这是我使用的一个老程序。
;;del_files.lsp
;;CAB 10/09/2006
;;Version 2.012.16.2009added file report & replace folder dialog
;;
;;User selects top folder, allows subfolders, enters file types
;;File types matching are then deleted.
;;
;;
(defun c:del_files (/CNTCNTFAILED F OutFile FNAME
FNAMELST FOLDER FTYPE FTYPES FULLPATH PATH
PLISTS usesub X get_subs *error*
)
;;===============================================
;; L o c a l F u n c t i o n s
;;===============================================
;; error function & Routine Exit
;|
(defun *error* (msg)
(if
(not
(member
msg
'("console break" "Function cancelled" "quit / exit abort" "")
)
)
(princ (strcat "\nError: " msg))
) ; endif
(if fso
(vlax-release-object fso)
)
(gc)
(princ)
)
|;
;; Return all directories
(defun get_subs (folder / file)
(mapcar '(lambda (x)
(setq file (strcat folder "\\" x))
(cons file (apply 'append (get_subs file)))
)
(cddr (vl-directory-files folder nil -1))
)
)
(vl-load-com)
;; FolderBox (Patrick_35)
(defun FolderBox (message directory flag / folder sh)
;; Arguments:
;; message: the message displayed in th dialog box
;; directory: the directory to browse
;; flag values:
;; 0 = Default
;; 1 = Only file system folders can be selected. If this bit is set, the OK button is disabled if the user selects a folder that doesn't belong to the file system (such as the Control Panel folder).
;; 2 = The user is prohibited from browsing below the domain within a network (during a computer search).
;; 4 = Room for status text is provided under the text box.
;; 8 = Returns file system ancestors only.
;; 16 = Shows an edit box in the dialog box for the user to type the name of an item.
;; 32 = Validate the name typed in the edit box.
;; 512 = None "New folder" button
;; 4096 = Enables the user to browse the network branch of the shell's namespace for computer names.
;; 8192 = Enables the user to browse the network branch of the shell's namespace for printer names.
;; 16384 = Allows browsing for everything.
(setq shell (vlax-create-object "Shell.Application"))
(if (setq
folder (vlax-invoke shell 'browseforfolder 0 message flag directory)
)
(setq folder (vlax-get-property (vlax-get-property folder 'self) 'path))
(setq folder nil)
)
(vlax-release-object shell)
folder
)
;;===========================================================
;; M a i n P r o g r a m
;;===========================================================
(setq path "" ; use current path
ftypes "" ; show all types
)
;;Old method (setq fullpath (getfiled "Select a File in the top folder." path ftypes 4) )
(setq fullpath (FolderBox "Select top folder for File Delete:"
;; (vl-filename-directory(findfile "acad.exe")) 0))
"c:" 0))
(if (and fullpath
;;Old method (setq path (vl-filename-directory fullpath)) ; extract path
(setq path fullpath) ; new method
;;(setq fname (vl-filename-base fullpath)) ; extract name only
;;(setq ftype (vl-filename-extension fullpath)) ; extract file type
)
(progn
(initget "Yes No")
(setq usesub (getkword "\nSearch in Subdirectories? "))
(or usesub (setq usesub "No"))
(initget "All bak bk1 bk2 sv$ ac$ log plt Ls Dc dS")
(setq ftype (getkword "\nEnter File type "))
(or ftype (setq ftype "bak"))
(cond
((member ftype '("Ls" "Dc")) ;correct for missing _ character
(setq ftype (list (strcat "_" ftype)))
)
((= ftype "All")(setq ftype '("bak" "bk1" "bk2" "sv$" "ac$" "log" "plt" "_Ls" "_Dc" "dS")))
(t (setq ftype (list ftype)))
)
(prompt "\n ***Working - Please wait***\n")
(if (= usesub "Yes")
(setq plists (cons (list path) (get_subs path))) ; use all subfolders too
(setq plists (list path)) ; only current path
)
(setq cnt 0
cntfailed 0
)
(if (setq OutFile (open (strcat path "\\FileDelList.txt") "w"))
(progn
(write-line
(strcat (substr (rtos (getvar "CDATE") 2 4) 5 2) ; month
"-" (substr (rtos (getvar "CDATE") 2 4) 7 2) ; day
"-" (substr (rtos (getvar "CDATE") 2 4) 1 4) ; year "2007"
) OutFile)
(write-line "=================================================" OutFile)
(foreach pl plists
(if (not (listp pl)) (setq pl (list pl)))
(foreach pa pl
(foreach ft ftype
;;get A LIST OF matching FILE NAMES
(setq fnamelst (vl-directory-files pa (strcat "*." ft) 1))
(if fnamelst
(foreach fn fnamelst
(if (vl-file-delete (strcat pa "\\" fn))
(progn
(write-line (strcat pa "\\" fn) OutFile)
(setq cnt (1+ cnt))
)
(setq cntfailed (1+ cntfailed))
)
)
)
)
)
)
(write-line "=================================================" OutFile)
(write-line (strcat (itoa cnt) " files were deleted.") OutFile)
(write-line (strcat (itoa cntfailed) " files could NOT be deleted.") OutFile)
(close OutFile) ; close the open file handle
)
)
(if (not (zerop cnt))
(prompt (strcat "\nReport File --> " path "\\FileDelList.txt \n"
(itoa cnt) " files were deleted.")))
(if (not (zerop cntfailed))
(prompt (strcat "\n" (itoa cntfailed) " files could NOT be deleted."))
)
(if (and (zerop cnt) (zerop cntfailed))
(prompt (strcat "\n***No matching files found***."))
)
)
(prompt "\nUser Quit.")
)
(princ)
)
我相信最好的办法是让你的创业公司有一个.bat,每次启动电脑时都要打扫房子。 检查日期,如果它早于某个日期,则删除。 我永远不会阻止他们被创造,不能告诉你他们救了我屁股多少次。
$0.02 好吧,我查了一下它们是什么。我同意,我不想全力以赴地摆脱它们。我喜欢启动时删除的想法。 :kewl:
(另外,我对lisp或编码或任何编程gobbledygook一无所知。 :丑陋:我甚至不知道如何运行一个。这是CAD中的同事学习的东西还是只是程序员? 都不是。AutoCAD中的LISP几乎都是防身学的。这门学科几乎没有课。
您不需要用LISP来做这件事,您可以用BAT文件来做。如果你不知道如何做到这一点,我强烈建议学习。这是一项非常有用的技能,不需要高深的编程知识。 Movebak,然后选择保存.bak文件的位置 我同意:就用MOVEBAK命令(我相信这是express工具的一部分)。这样做不需要lisp。
页:
[1]
2