Solved

Batch File to Rename a file

Posted on 2013-12-13
5
398 Views
Last Modified: 2013-12-15
need a batch file line to  "Rename" a file instead of deleting it on the laptop..



for %%a in  (C) do del "%%a":\Data2013.xlam /s /f

I need this file to get renamed from

"Data2013.xlam"  to   "Current_Data2013.xlam"



Thanks
fordraiders
0
Comment
Question by:fordraiders
[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
5 Comments
 
LVL 37

Accepted Solution

by:
TommySzalapski earned 400 total points
ID: 39717628
Use ren instead of del
for %%a in  (C) do ren "%%a":\Data2013.xlam "%%a":\Current_Data2013.xlam /s /f
0
 
LVL 8

Expert Comment

by:5teveo
ID: 39717646
for %%a in (*.xlam) do ren "%%a" "Current_%%a"
0
 
LVL 6

Assisted Solution

by:Tomislavj
Tomislavj earned 100 total points
ID: 39717672
try this

@echo off

REM Save file in a directory where files are

REM Prefix to add to the filename
set strPrefix=Current_

REM set what files need to be renamed
set fname=Data2013.xlam

REM List the files to be renamed for checking
for %%f in (%fname%) DO echo Rename file "%%f" to "%strPrefix%%%f"

REM Rename the files (remove the REM from next line) for REAL!!
REM for %%f in (%fname%) DO ren "%%f" "%strPrefix%%%f" 

Open in new window

0
 
LVL 3

Author Closing Comment

by:fordraiders
ID: 39719574
Thanks
0
 
LVL 3

Author Comment

by:fordraiders
ID: 39720681
i get an error now on:

for %%a in  (C) do ren "%%a":\Data2013.xlam "%%a":\Current_Data2013.xlam /s /f

not correct syntax ?
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this post we will learn different types of Android Layout and some basics of an Android App.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

628 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