Solved

Batch file for excel purposes not executing correctly.

Posted on 2013-12-16
10
189 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
  • 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
 
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
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!

 
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
sumHeights2  challenge 7 76
array11 challenge 16 51
strDist challenge 35 84
Controlled Assessment GCSE - desperate help needed 4 53
I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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…

757 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

24 Experts available now in Live!

Get 1:1 Help Now