Solved

Batch file for excel purposes not executing correctly.

Posted on 2013-12-16
10
190 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
countHi challenge 25 101
listing all functions in JavaScript 19 180
Meaning of "exceptions()" in "ist.exceptions( ist.exceptions() | ios_base:: badbit);" 3 56
Advice in Xamarin 21 57
This is about my first experience with programming Arduino.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
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 seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

863 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

26 Experts available now in Live!

Get 1:1 Help Now