Jump to content

Recommended Posts

Posted

DOS supports only 8 character file names

 

Lee's way is probably better with long file names.

  • Replies 33
  • Created
  • Last Reply

Top Posters In This Topic

  • dbroada

    9

  • ReMark

    9

  • Lee Mac

    6

  • Phiphi

    4

Top Posters In This Topic

Posted Images

Posted

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

dos.jpg

Posted

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.

Rename.jpg

Posted

I totally agree with the two guys above. That's so rare the world as we know it may end prematurely. LOL

  • 2 months later...
Posted

and I'm back here trying to remember how to do this. :)

 

yea! it still works

  • 1 month later...
Posted
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

Posted

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

Posted

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

 

 

Posted

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

Posted

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.

  • 4 months later...
Posted

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.

Posted

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

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...