BIGAL Posted December 23, 2009 Posted December 23, 2009 DOS supports only 8 character file names Lee's way is probably better with long file names. Quote
dbroada Posted December 23, 2009 Author Posted December 23, 2009 DOS may only allow 8 characters but you can still access their long names from the command prompt where the old DOS commands still work Quote
eldon Posted December 23, 2009 Posted December 23, 2009 Having tested it before I posted, I can confirm that the Command Prompt does allow long file names and "ren" does work for multiple files with different extensions. Quote
ReMark Posted December 23, 2009 Posted December 23, 2009 I totally agree with the two guys above. That's so rare the world as we know it may end prematurely. LOL Quote
dbroada Posted February 26, 2010 Author Posted February 26, 2010 and I'm back here trying to remember how to do this. yea! it still works Quote
Phiphi Posted March 28, 2010 Posted March 28, 2010 This should work in LISP: (defun c:DocSuff (/ *error* *acad FOLDER FPATH SHELL SUFF) (vl-load-com) ;; Suffix Filename ~ Lee Mac (defun *error* (msg) (and Shell (not (vlax-object-released-p Shell)) (vlax-release-object Shell)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ)) (setq Suff (getstring t "\nSpecify Suffix: ") *acad (vlax-get-acad-object) shell (vla-getInterfaceObject *acad "Shell.Application") folder (vlax-invoke-method shell 'BrowseForFolder (vla-get-HWND *acad) "Select Directory" 0)) (vlax-release-object shell) (if folder (progn (setq fpath (vlax-get-property (vlax-get-property folder 'Self) 'Path)) (and (/= (substr fpath (strlen fpath)) "\\") (setq fpath (strcat fpath "\\"))) (foreach dwg (mapcar (function (lambda (x) (strcat fpath x))) (vl-directory-files fpath "*.dwg" 1)) (vl-file-rename dwg (strcat fpath (vl-filename-base dwg) Suff ".dwg")))) (princ "\n*Cancel*")) (princ)) Will rename all in a directory. Hi Lee, I have added PreFix to your SufFix Lisp as attached below. Can you able to use Lisp to rename all cadfiles in a folder with brand new filename as users specify (ex. 123456A-STR-0001 Lisp will rename to 123456A-STR-0001, 123456A-STR-0002 , 123456A-STR-0003... to end list of files). Old filenames will be overwritten and a list of new filenames should be shown in AutoCAD Text Window as well. Thank you. PP. RENAME CADFILES.lsp Quote
Phiphi Posted March 28, 2010 Posted March 28, 2010 I just found out a "Free File Rename Utility for Windows. Rename multiple files with the click of a button. Batch renaming made easy" A small freeware program (1.8mb) but can rename any form of filename that you want. Here is the website of BULK RENAME UTILITY: http://www.bulkrenameutility.co.uk/Main_Intro.php Quote
Lee Mac Posted March 28, 2010 Posted March 28, 2010 Hi PP, This should work, but be careful. ;; Will Rename all files in a directory using a Prefix String ;; and incrementing Suffix String. Suffix will be padded with ;; leading zeros. Function will only process integer valued ;; Increments. (defun c:FileRename (/ *error* ZeroPad *ACAD FOLDER FPATH INC LEN PREF SHELL) (vl-load-com) ;; Lee Mac ~ 28.03.10 (defun *error* (msg) (and Shell (not (vlax-object-released-p Shell)) (vlax-release-object Shell)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ)) (defun ZeroPad (s l) (while (< (strlen s) l) (setq s (strcat "0" s))) s) (if (atoi (setq Pref (getstring t "\nSpecify Prefix String: ") Inc (getstring "\nSpecify Incrementing String: "))) (progn (setq *acad (vlax-get-acad-object) shell (vla-getInterfaceObject *acad "Shell.Application") folder (vlax-invoke-method shell 'BrowseForFolder (vla-get-HWND *acad) "Select Directory to Rename" 0) Len (strlen Inc)) (vlax-release-object shell) (if folder (progn (setq fpath (vlax-get-property (vlax-get-property folder 'Self) 'Path)) (or (= (substr fpath (strlen fpath)) "\\") (setq fpath (strcat fpath "\\"))) (foreach dwg (mapcar (function (lambda (x) (strcat fpath x))) (vl-directory-files fpath "*.dwg" 1)) (vl-file-rename dwg (strcat fpath Pref Inc ".dwg")) (setq Inc (ZeroPad (itoa (1+ (atoi Inc))) Len)))) (princ "\n*Cancel*")))) (princ)) Quote
Phiphi Posted March 28, 2010 Posted March 28, 2010 Thanks Lee, A list of new filenames should be shown so that User can click Yes/No before renamed or as you said "Be careful!" Quote
Tankman Posted March 28, 2010 Posted March 28, 2010 DOS does go on! I frequently use the DOS prompt to rename (ren) a file or two. I don't have very lengthy file names either. Quote
Phiphi Posted August 2, 2010 Posted August 2, 2010 There is an excel sheet with two columns: -Column A: Old filenames -Column B: New filenames Can Lisp reads this sheet then rename all filenames? Please help. Thanks. Quote
DVDM Posted August 4, 2010 Posted August 4, 2010 I use Total Commander for all my file renaming needs (plus any other file management issues that may arise). It has the facility to rename files based on input of a list. www.ghisler.com Quote
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.