I'm trying to renaming files by selecting a directory folder and renaming the files using ObjectDBX.
1). Is this even possible?
2). Could it be done by using part of the folder name, like the first part of the drawing name: 170021 and substituting it with the six numbers of the folder
name. Ex: "170021 Smith BasePlan.dwg" found in folder name "170034 Smith", the drawing would be renamed to "170034 Smith BasePlan.dwg"?
I would like to use ObjectDBX to accomplish this.
Here are some example of using only AutoLisp and not ObjectDBX.
(defun C:RN-1 (/ filen1 filen2 num)
(setq filen1 (strcat (getvar "dwgprefix") (getvar "dwgname")))
(setq num (strlen
(substr (getvar "dwgprefix") 12 (- (strlen (getvar "dwgprefix")) 12))))
(prompt "\n* Saveas Open drawing with New Folder Name...")
(setq filen2
(strcat (substr (getvar "dwgprefix") 12 (- (strlen (getvar "dwgprefix")) num))
(substr (getvar "dwgname") 13 (- (strlen (getvar "dwgprefix")) 11))))
(command "_.saveas" "" (strcat (getvar "dwgprefix") filen2))
(dos_rename filen1 filen2)
(dos_delete filen1)
(princ))
(defun c:RN-2 (/ old new f)
(if (null dos_about)
(arxload "doslib2k.arx"))
(if (null *dir*)
(setq *dir* (getvar "dwgprefix")))
(setq old (getstring T "Enter Old Name: "))
(setq new (getstring T "Enter New Name: "))
(setq f (dos_getfilem "Select File(s)" *dir* "All Files (*.*)|*.*"))
(cond (f
(setq *dir* (car f))
(setvar "CMDECHO" 0)
(foreach
dwgfile (acad_strlsort (cdr f))
(vl-file-rename
(strcat *dir* dwgfile)
(strcat *dir* (vl-string-subst new old dwgfile))))))
(if dos_about
(arxunload "doslib2k.arx"))
(princ))
Any help would be appreciated
Gary