Solved

Batch file for excel purposes not executing correctly.

Posted on 2013-12-16
10
194 Views
Last Modified: 2013-12-17
I have a .bat  file that i need to rename a file to another name.

The file could be anywhere on the pc..


i get an error now on:

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

not correct syntax ?

Any Help please.

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
  • 4
10 Comments
 
LVL 17

Expert Comment

by:Chris Millard
ID: 39722819
I'm on a Mac at the moment, so cannot confirm but I think you need to add a colon ':' after the (C so that it reads:-

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

Accepted Solution

by:
DiscGolfDad earned 500 total points
ID: 39722828
Leave off the quotation marks (")

for %%a in (C) do ren %%a:\Data2013.xlam %%a:\Current_Data.xlam /s /f
0
 
LVL 3

Author Comment

by:fordraiders
ID: 39724407
neither suggestion is working...sorry.
0
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!

 
LVL 2

Expert Comment

by:DiscGolfDad
ID: 39724462
The syntax I gave you is correct, but I'm not sure why you are using the For %%A in to begin with.  You state you are only changing one file, and by specifying only one parameter (C) it is only processing one file and hence is redundant.  If the command does not work without the for %%a in part then it won't work with it, either.  I am not aware of any parameters (/s /f) to the ren (rename) statement at all.  If you type ren /? it will show you the proper syntax ren.  What the For %%a in is supposed to be used for is something more like this:

for %%a in (c d e f) do if exist %%a:\orgfile.txt ren %%a:\orgfile.txt newfile.txt
0
 
LVL 3

Author Comment

by:fordraiders
ID: 39724669
ok..i need it to look anywhere on the computer..in any folder.. on C:\
0
 
LVL 2

Expert Comment

by:DiscGolfDad
ID: 39725156
I've been writing batch files for 30 years, and I know of nothing that will do that through a command prompt.  You'd probably have to have a custom program to accomplish that.
0
 
LVL 3

Author Comment

by:fordraiders
ID: 39725279
so u have to specify a folder location explicitaly ?
0
 
LVL 2

Expert Comment

by:DiscGolfDad
ID: 39725339
Yes, exactly.  Wildcards can be used in filenames, but not folders.
0
 
LVL 3

Author Comment

by:fordraiders
ID: 39725383
ok Thanks
0
 
LVL 3

Author Closing Comment

by:fordraiders
ID: 39725384
Thanks
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Part One of the two-part Q&A series with MalwareTech.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Starting up a Project

617 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