|
Answer» Hi,
I am very naive to "batch file programming"
Basically i want to achieve, the following
I want to update a list of file names (along with extension) at a particular position in a text file., using a batch file.
For instance,
If the current directory has "a.c and b.c" files, and there is a text file named "code.txt", which has the following pattern
SOURCES= \ ..\a.c \ ..\b.c \
If i run the batch file, i would like to search for string SOURCES in the code.x, update the file names (with *.c) at the desired LOCATION as specified above
Please help me in providing information, any example code or any other link which gives information in achieving the same
Many thanks in advance,
Regards, tspso what is the final output of your code.txt look like? describe PROPERLY what you want...what do you mean by update the file names with ".c" is it you want to update your files in your directory?? or the contents of code.txt?If the format of code.txt is what you showed, then this should work.
@for /f "tokens=1-2 delims= " %%a in ('type code.txt') do REN %%a %%b
That should work as long as there are no spaces in the files' paths. I'm not 100% sure the second file (the name what it will be renamed to) requires a full path, but it won't hurt if it does.@helpmeh , the current directory already has a.c and b.c and the code.txt presented also has that....so i am not sure if OP's has described his REQUIREMENT properly.Hello,
Thanks for reply, and Sorry for not bringing the clarity at first shot !
The scenario is: - A directory there are 2 files (a.c and b.c) - C source code files and a text file has " code.txt " file. - Typically the code.txt could look like the following initially
< SOME TEXT - LIKE DEFINES >
SOURCES=
< SOME PATH - DETAILS >
- My objective is to find all the .c files residing in the current directory and place it in " code.txt" file Considering the above scenario,
I need to create a batch file, which reads all the .c files and updates the code.txt file, such that after execution of the batch file, the code.txt file would look like:
< ADDITIONAL CODE - SOME TEXT - LIKE DEFINES >
SOURCES= \ ..\a.c \ ..\b.c \
< ADDITIONAL CODE - SOME PATH - DETAILS >
My objective is to create a batch file , which does the above !
Do let me know if in case am not clear
Regards, tsp Hi All,
Or a simipler version of my requirement would be to
replace the output of
dir /b *.c command
in file code.txt under
SOURCES=/
Thank you,
Regards, tsp
|