Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Batch file for excel purposes not executing correctly.

Posted on 2013-12-16
10
Medium Priority
?
195 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 2000 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
The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
Simple Linear Regression
Starting up a Project

721 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