?
Solved

Save as file in a Dos Bat file

Posted on 2013-12-04
7
Medium Priority
?
356 Views
Last Modified: 2013-12-06
I have files being sent to my C:\temp directory.  Each file has the date added to it.

Example: ABNAVWH_12/05/2013.CSV   I would like to have it renamed to only ABNAVWH.CSV

Meaning I need the date striped away from the file.

I have multiple files and so far I have been doing this manually.  Is there a easier way to handle this?
0
Comment
Question by:ICTIndika
[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
  • 2
  • 2
7 Comments
 

Author Comment

by:ICTIndika
ID: 39697455
Thanks for letting me Know.  I believe a Dos solution would be the best bet.
0
 
LVL 17

Expert Comment

by:Lior Karasenti
ID: 39697663
This script should do:
@echo off
cd /d "C:\Temp"
for /f "delims=_ tokens=1,*" %%a in ('dir /b /aa') do ren "%%a_%%b" "%%~na%%~xb"
goto :eof

Open in new window

0
 

Author Comment

by:ICTIndika
ID: 39697677
Thanks.  This worked great
0
 
LVL 43

Accepted Solution

by:
Steve Knight earned 1500 total points
ID: 39700686
Aside from not being able to have / in the filename you can do it much simpler using just this:

ren *.csv ???????.csv

And it will rename to the first 7 chars worth of the filename

Steve
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 39702774
Erm, why the B grade?
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
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…
Suggested Courses
Course of the Month7 days, 22 hours left to enroll

765 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