Computing.Net > Forums > Disk Operating System > Dos ren - filenames inc periods

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Dos ren - filenames inc periods

Reply to Message Icon

Name: knightta
Date: November 22, 2004 at 08:41:51 Pacific
OS: nt
CPU/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.




Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: November 22, 2004 at 21:31:15 Pacific
Reply:

I'm running 2k, not NT. But in 2k the usual fix is double quote the name.

HTH

M2


0

Response Number 2
Name: knightta
Date: November 23, 2004 at 04:05:39 Pacific
Reply:

Sorry, double quotes make absolutely no difference?

Surely this must be possible?

....or maybe not!

*throws down a challenge*


0

Response Number 3
Name: Mechanix2Go
Date: November 23, 2004 at 04:24:15 Pacific
Reply:

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


0

Response Number 4
Name: knightta
Date: November 23, 2004 at 04:50:40 Pacific
Reply:

thanks M2...I'll try to catch the others when they're sleeping!


0

Response Number 5
Name: IVO
Date: November 23, 2004 at 05:42:16 Pacific
Reply:

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


0

Related Posts

See More



Response Number 6
Name: Mechanix2Go
Date: November 23, 2004 at 07:14:01 Pacific
Reply:

No slack in light attack.

M2


0

Response Number 7
Name: IVO
Date: November 23, 2004 at 07:31:58 Pacific
Reply:

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.


0

Response Number 8
Name: Mechanix2Go
Date: November 23, 2004 at 08:09:19 Pacific
Reply:

[smoke runs out of my ears]

52

M2


0

Response Number 9
Name: knightta
Date: November 23, 2004 at 08:57:36 Pacific
Reply:

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.


0

Response Number 10
Name: IVO
Date: November 23, 2004 at 09:15:29 Pacific
Reply:

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?


0

Response Number 11
Name: Mechanix2Go
Date: November 23, 2004 at 09:22:36 Pacific
Reply:

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


0

Response Number 12
Name: knightta
Date: November 23, 2004 at 09:49:51 Pacific
Reply:

yes, test directory stores the jpg files
and I called the .bat file myren.bat

Thanks


0

Response Number 13
Name: IVO
Date: November 24, 2004 at 00:43:13 Pacific
Reply:

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.


0

Response Number 14
Name: knightta
Date: November 24, 2004 at 04:13:56 Pacific
Reply:

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.


0

Response Number 15
Name: Mechanix2Go
Date: November 24, 2004 at 04:37:30 Pacific
Reply:

Tom,

Glad it flew.

The rocket scientists's name is IVO. You can learn a lot by reading his msgs.


M2


0

Response Number 16
Name: knightta
Date: November 24, 2004 at 05:20:07 Pacific
Reply:

Ha, what a typo!
cheers M2, IVO

I'm sure I'll return.


0

Response Number 17
Name: IVO
Date: November 24, 2004 at 05:28:57 Pacific
Reply:

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.


0

Response Number 18
Name: Mechanix2Go
Date: November 24, 2004 at 21:32:09 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Dos ren - filenames inc periods

Adding a date to a filename www.computing.net/answers/dos/adding-a-date-to-a-filename/13542.html

Zipping files using Dos Commands. www.computing.net/answers/dos/zipping-files-using-dos-commands/10548.html

dos editor is not open file www.computing.net/answers/dos/dos-editor-is-not-open-file/9630.html