dbroada Posted December 22, 2009 Posted December 22, 2009 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. Quote
ReMark Posted December 22, 2009 Posted December 22, 2009 The old REN command as it was referred to in DOS. Still can be used in Windows from a command line prompt. Quote
dbroada Posted December 22, 2009 Author Posted December 22, 2009 that's what I'm using, I can't find the syntax to add the -T afer the file name but before the .dwg Quote
ReMark Posted December 22, 2009 Posted December 22, 2009 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. Quote
Lee Mac Posted December 22, 2009 Posted December 22, 2009 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. Quote
ReMark Posted December 22, 2009 Posted December 22, 2009 Renaming files and directories (folders) for DOS and Windows users. http://www.computerhope.com/issues/ch000846.htm#4 I think you just need a wildcard. Quote
dbroada Posted December 22, 2009 Author Posted December 22, 2009 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. Quote
Lee Mac Posted December 22, 2009 Posted December 22, 2009 ... (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 Quote
ReMark Posted December 22, 2009 Posted December 22, 2009 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? Quote
dbroada Posted December 22, 2009 Author Posted December 22, 2009 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. Quote
eldon Posted December 22, 2009 Posted December 22, 2009 Doesn't DOS have an eight character limit on file names? Quote
dbroada Posted December 22, 2009 Author Posted December 22, 2009 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. Quote
Lee Mac Posted December 22, 2009 Posted December 22, 2009 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 Quote
ReMark Posted December 22, 2009 Posted December 22, 2009 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. Quote
eldon Posted December 22, 2009 Posted December 22, 2009 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. Quote
dbroada Posted December 22, 2009 Author Posted December 22, 2009 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 Quote
ReMark Posted December 22, 2009 Posted December 22, 2009 Dave: For a single file eldon's way does work. Just tried it out myself using the drawing file name you provided. Quote
dbroada Posted December 22, 2009 Author Posted December 22, 2009 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. Quote
ReMark Posted December 22, 2009 Posted December 22, 2009 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. 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.