Solved

Batch file for excel purposes not executing correctly.

Posted on 2013-12-16
10
191 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
ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

 
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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupNoAdj 7 96
White board coding practice 3 88
How to get time difference in minutes and seconds only between 2 dates 2 41
Cygwin - GNU GPL License 1 24
This article will show, step by step, how to integrate R code into a R Sweave document
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.
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 …
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…

777 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