Fordraiders
asked on
Batch file for excel purposes not executing correctly.
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.xl am /s /f
not correct syntax ?
Any Help please.
fordraiders
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.xl
not correct syntax ?
Any Help please.
fordraiders
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
neither suggestion is working...sorry.
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
for %%a in (c d e f) do if exist %%a:\orgfile.txt ren %%a:\orgfile.txt newfile.txt
ASKER
ok..i need it to look anywhere on the computer..in any folder.. on C:\
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.
ASKER
so u have to specify a folder location explicitaly ?
Yes, exactly. Wildcards can be used in filenames, but not folders.
ASKER
ok Thanks
ASKER
Thanks
for %%a in (C:) do ren "%%a":\Data2013.xlam "%%a":\Current_Data2013.xl