Solved

Batch File to Rename a file

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

710 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