Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

MS DOS | Append a second file ext.

Posted on 2010-11-24
12
Medium Priority
?
496 Views
Last Modified: 2012-05-10
I have a directory with a dozen or so files that get created every day.

10001.J123
10002.J123
10003.J123

I need to keep the ".J###" for the job number but add ".DONE" to the end.

1001.J123.DONE
1002.J123.DONE
1003.J123.DONE

Any suggestions?
0
Comment
Question by:blannan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
  • +2
12 Comments
 
LVL 6

Expert Comment

by:rnicolaus
ID: 34205900
I have used the freeware Bulk Rename Utility for a task very similar
http://www.bulkrenameutility.co.uk/Main_Intro.php
It can be scheduled as well with Bulk Command Line
0
 
LVL 43

Assisted Solution

by:Steve Knight
Steve Knight earned 400 total points
ID: 34206221
If you want it as a batch command try:

@echo off
for /f "tokens=*" %%a in ('dir /b /a-d *.j* ^|find /v ".DONE"') do rename "%%a" "%%a.DONE"

That will run down all files called *.j* except those with .DONE in the name and rename them by adding .DONE on the end.

If you want to run it from a command prompt rather than batch file replace each %%a with %a

Steve
0
 

Author Comment

by:blannan
ID: 34207006
Sorry I did not mention that I needed a batch command. Thanks dragon-it I am going to test this today.
0
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 
LVL 71

Accepted Solution

by:
Qlemo earned 1600 total points
ID: 34207052
ren *.j*. *.*.DONE

Open in new window

should work, but Steve's command is more safe.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 34209426
I was going to do that to start with but couldn't get it to work Qlemo, i.e. along these lines:

C:\Documents and Settings\stephen\26256550>rename *.j*. *.DONE
A duplicate file name exists, or the file cannot be found.
A duplicate file name exists, or the file cannot be found.
A duplicate file name exists, or the file cannot be found.

i.e. it renames file #1 to *.DONE without the .j* bit then complains for each other one as it duplicates
0
 
LVL 71

Expert Comment

by:Qlemo
ID: 34209535
It did work for me on XP, Vista, W7.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 34209596
Sorry Qlemo, would help if I read right.... it DOES work fine like you say - if you add the exta *. I had missed out of the dest. filename too.  

I confirm Qlemo's post works fine for me too! (ren *.j*. *.*.DONE)

Steve
0
 
LVL 58

Expert Comment

by:Bill Prew
ID: 34209756
Yes, that will work, but it the "DONE"s stay in the same folder then the next time around they will get another .DONE on the end.  So it depends on how the poster intends to manage these files, if they get moved out right after the rename then the Q approach works, but if they will stay in the folder afterwards while new files come in and need to be renamed then something like Steve's logic is need to skip offer the "DONE" ones.

~bp
0
 
LVL 71

Expert Comment

by:Qlemo
ID: 34209765
No, they won't get renamed again. The mask   *.j*.   will not find those files.
0
 
LVL 58

Expert Comment

by:Bill Prew
ID: 34209841
Interesting, I played with this question after Steve posted looking for a way to do it all with a single REN, and could have sworn I tried that, but obviously I must have had it a bit different.

Sorry for the confusion, props to Qlemo for the simple solution.

~bp
0
 
LVL 71

Expert Comment

by:Qlemo
ID: 34209854
I have been surprised myself that it works ;-).
0
 
LVL 58

Expert Comment

by:Bill Prew
ID: 34209869
I think "you're just that good" Q!

:-)
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question