Jump to content

Recommended Posts

Posted

I have a bunch of files to rename from (typically) E343-12-GA-0001-01.dwg to E343-12-GA-0001-01-T.dwg

 

I used to be able to do this in DOS but I have forgotten how. When I try now I get E343-12-GA-0001-T.dwg (note the absence of -01)

 

anybody want to help me out?

 

I am currently renumbering my files by doing a dir.* /b > renumber.bat and editing the file in EXCEL but this more prone to operator error than the other way.

 

I don't need to use DOS if there is a windows command available.

  • 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

The old REN command as it was referred to in DOS. Still can be used in Windows from a command line prompt.

Posted

that's what I'm using, I can't find the syntax to add the -T afer the file name but before the .dwg

Posted

Try looking in Windows Explorer under Help. Search for rename files. One of the results will be Rename (REN). I'm pretty sure all the syntax is explained there.

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.

Posted

thanks for the suggestions guys, in the end it wasn't too bad using excel - I just had to set it up once then copy & paste the list into one column and copy the modified list back to the file and rename it .bat, click and all done.

 

Mark, all the example I could find would CHANGE a part of the file name (say 5th letter) but not add to it. Still can't remember how to append a part (other than programatically - thanks Lee, I was going to VB it but you were quicker) within the name. I thought I used to know how but maybe not.

Posted
... (other than programatically - thanks Lee, I was going to VB it but you were quicker)

 

No worries, whatever works for you - I just stick to what I know :)

Posted

Example: Rename two files called plot.log and replot log to plot-T.log and replot-T.log using DOS.

 

ren *.* *-T.*

 

This assumes that there are no other file extensions in the folder since the * is a wildcard. If there are we must get specific and type:

 

ren *.log *-T.log

 

Ring any bells there Dave?

Posted
Example: Rename two files called plot.log and replot log to plot-T.log and replot-T.log using DOS.

 

ren *.* *-T.*

 

This assumes that there are no other file extensions in the folder since the * is a wildcard. If there are we must get specific and type:

 

ren *.log *-T.log

 

Ring any bells there Dave?

that is what I (thought I) tried but I just got 12345678.dwg > 123456-T.dwg

 

could be operator error though. I have another set to rename next year. I'll see if I can remember it then. :)

Posted

Doesn't DOS have an eight character limit on file names?

Posted

I guess pure DOS does but the "command prompt" that comes with XP looks like DOS and smell like DOS so I call it DOS - and it doesn't have that restriction.

Posted
I guess pure DOS does but the "command prompt" that comes with XP looks like DOS and smell like DOS so I call it DOS - and it doesn't have that restriction.

 

If all else fails - just use VB / LISP :)

Posted

I think I may be in error. The rename above may return something like this:

 

plot.log-T.log and not plot-T.log

 

I'd have to test it out. I know I could do it if it only involved one file because it could be written very specific. Example: ren plot.log plot-T.log Renaming multiple files would have to be done differently. Something to think about.

Posted

Try using query marks instead of each character in the file name thus:-

 

ren ??????????????????.* ??????????????????-T.*

 

A wildcard * seems to behave strangely, when used as the file name.

Posted

I think that may be how I did it in the past!

 

This time I tried

ren ???????????????????.dwg *-T.dwg

 

but just got the last 2 chars changed and then it left me in a mess as those numbers are the sheet designation so sheet T now already exists IYSWIM.

 

I'll give that a try on the next set :)

Posted

Dave: For a single file eldon's way does work. Just tried it out myself using the drawing file name you provided.

Posted

it should work on a complete directory too provided the correct number of ? are supplied. Once I saw it I thought "THAT'S I! How did I forget. Doh"

 

Oh well, one set done and I currently know how to do the other set. And if I forget after Christmas I should be able to come back here and remind myself.

Posted
Doesn't DOS have an eight character limit on file names?

 

That was overcome during the evolution of Windows to allow for long file names.

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