Solved

Batch File to Rename a file

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This is an explanation of a simple data model to help parse a JSON feed
This is about my first experience with programming Arduino.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now