Solved

Batch File to Rename a file

Posted on 2013-12-13
5
394 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
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.

685 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