|
|
|
Dos ren - filenames inc periods
|
Original Message
|
Name: knightta
Date: November 22, 2004 at 08:41:51 Pacific
Subject: Dos ren - filenames inc periodsOS: ntCPU/Ram: 400 |
Comment: I need to rename some files; they have periods in the filenames and this seems to fox ren. I would like to rename files like 012_11.03.12.1ic_NCS_LI.jpg 002_11.03.12.1ba_ NS_LI.jpg 012_11.03.12.1ic_LI.jpg 002_11.03.12.1ba_LI.jpg ie remove the _NCS or _NS component I've tried: h:\test\????????????????*.jpg ????????????????_LI.jpg but this truncates at the first . to 001_11_LI.jpg 002_11_LI.jpg am i right in thinking it's the periods which it doesn't like...and is there a smart solution? Thanks in advance, Tom.
Report Offensive Message For Removal
|
|
Response Number 2
|
Name: knightta
Date: November 23, 2004 at 04:05:39 Pacific
Subject: Dos ren - filenames inc periods |
Reply: (edit)Sorry, double quotes make absolutely no difference? Surely this must be possible? ....or maybe not! *throws down a challenge*
Report Offensive Follow Up For Removal
|
|
Response Number 3
|
Name: Mechanix2Go
Date: November 23, 2004 at 04:24:15 Pacific
Subject: Dos ren - filenames inc periods |
Reply: (edit)Tom, I'm almost sure it's possible. And I'll bet IVO or jboy could do it in their sleep. I'll work on it. I got a right to be slow; I'm old. M2
Report Offensive Follow Up For Removal
|
|
Response Number 5
|
Name: IVO
Date: November 23, 2004 at 05:42:16 Pacific
Subject: Dos ren - filenames inc periods |
Reply: (edit)Well, I did not answer to the post as that is a NT question not a DOS one, but here is the solution and you have to thank Mechanix2Go if you get it. Save the batch naming as you want and type RPer Folder (I named it RPer - Folder is the folder storing the *.jpg)) and you are done. @Echo Off Set JDir=%* For /F "tokens=*" %%A in ('Dir "%JDir%\*.jpg" /B') Do Call :REN %%A Set JDir= GoTo :EOF :REN Set OldF=%* Set NewF=%OldF:_NCS=% If "%NewF%"=="%OldF%" Set NewF=%OldF:_NS=% Ren "%JDir%\%OldF%" "%NewF%" Set OldF= Set NewF= GoTo :EOF
Report Offensive Follow Up For Removal
|
|
Response Number 7
|
Name: IVO
Date: November 23, 2004 at 07:31:58 Pacific
Subject: Dos ren - filenames inc periods |
Reply: (edit)Hi Mechanix2Go, I'm not just a kid! I run my first program (a FORTRAN IV procedure simulating tankers refilling) on an IBM 7040 in 1972 as my assignment for the Operation Research class at University. That was the classical glass-room monster, a pre 360/370 computer era. So try to compute my age, baby. PS: that program never worked as planned.
Report Offensive Follow Up For Removal
|
|
Response Number 9
|
Name: knightta
Date: November 23, 2004 at 08:57:36 Pacific
Subject: Dos ren - filenames inc periods |
Reply: (edit)Sorry to interupt the banter... this is my first .bat (the first time is always the best) and I can't get it to work: H:\>myren test The system cannot find the file specified. both myren.bat and test file are in H:\> Thanks, Tom.
Report Offensive Follow Up For Removal
|
|
Response Number 10
|
Name: IVO
Date: November 23, 2004 at 09:15:29 Pacific
Subject: Dos ren - filenames inc periods |
Reply: (edit)Hi Tom, is myren the batch I posted?. If yes, it is planned to process .jpg files. If none exists it returns an error message. So is test Directory storing .jpg files?
Report Offensive Follow Up For Removal
|
|
Response Number 11
|
Name: Mechanix2Go
Date: November 23, 2004 at 09:22:36 Pacific
Subject: Dos ren - filenames inc periods |
Reply: (edit)Tom. Is 'test' the FOLDER? IVO sez: "(I named it RPer - Folder is the folder storing the *.jpg)" As long as you're starting out, get used to the idea that as far as a command interpreter is concerned [be it DOS or NT / 2k /XP emulation] there are no folders. There are files, directories and not much else. M2
Report Offensive Follow Up For Removal
|
|
Response Number 12
|
Name: knightta
Date: November 23, 2004 at 09:49:51 Pacific
Subject: Dos ren - filenames inc periods |
Reply: (edit)yes, test directory stores the jpg files and I called the .bat file myren.bat Thanks
Report Offensive Follow Up For Removal
|
|
Response Number 13
|
Name: IVO
Date: November 24, 2004 at 00:43:13 Pacific
Subject: Dos ren - filenames inc periods |
Reply: (edit)Sorry to be back only now, according to your post the trouble is related to the Ren statemant. As I tested the batch and it run fine on my system, please may you run the script coding an Echo before the Ren and report exactly what is displayed?. I need your help to debug.
Report Offensive Follow Up For Removal
|
|
Response Number 14
|
Name: knightta
Date: November 24, 2004 at 04:13:56 Pacific
Subject: Dos ren - filenames inc periods |
Reply: (edit)Both your .bat file and the suggestion of using double quotes for ren on the command line worked when I got home on XP. Clearly an NT problem. As originally mentioned, perhaps this wasn't the right place to raise the issue! incidently adding Echo before the ren command the .bat file provided again gives C:\>myren test The system cannot find the file specified. when both myren (the .bat) and test (containing the files) are in root. Anyway, we got the job done...and many thanks OVM and M2 you have saved my colleagues many hours of tedious work. And I'm no longer a .bat virgin! Thanks, Tom.
Report Offensive Follow Up For Removal
|
|
Response Number 15
|
Name: Mechanix2Go
Date: November 24, 2004 at 04:37:30 Pacific
Subject: Dos ren - filenames inc periods |
Reply: (edit)Tom, Glad it flew. The rocket scientists's name is IVO. You can learn a lot by reading his msgs. M2
Report Offensive Follow Up For Removal
|
|
Response Number 17
|
Name: IVO
Date: November 24, 2004 at 05:28:57 Pacific
Subject: Dos ren - filenames inc periods |
Reply: (edit)A last note, even if we can never know the unknown: the behavior of myren script should be invariant under NT. Actually I tested it under Win XP and 2000 where it worked fine. The same I supposed under NT, those systems all sharing the same kernel. Microsoft OS are really an unended challenge! PS for Mechanix2Go: You was smart in computing my age, but I can't give you the reward (€ 1.000.000), as the correct response is 54. Never mind, you lack some marginal data: in Italy a doctorate enginnering degree required at that time 5 years and I was late to face programming as I spent the first three years in the Nuclear Enginnerring course reverting to the Electrical one only the last two years. Next time you'll be more lucky.
Report Offensive Follow Up For Removal
|
|
Response Number 18
|
Name: Mechanix2Go
Date: November 24, 2004 at 21:32:09 Pacific
Subject: Dos ren - filenames inc periods |
Reply: (edit)IVO, I wish I was 54 again. In '72 I was majoring in girls an math. Tom, you can perhaps appreciate why some here are sticklers for exact OS / conditions. One size does not fit all except in the most trivial BAT files. M2
Report Offensive Follow Up For Removal
|
Use following form to reply to current message:
|
|

|