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
Solved

Batch File to Rename a file

Posted on 2013-12-13
5
393 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
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

Suggested Solutions

Title # Comments Views Activity
What language/protocol is the Angular Chat? 2 86
Capture logon name 13 87
What does != "" mean in programming 8 80
AvlTree-Node Data type 4 14
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

861 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