|Hi M2G. |
But why? > newfile & setLocal EnableDelayedExpansion
Only the first word in the first line of the text file is being extracted, delayed expansion is not required (?) and no file is being written until Copy is executed. No local or global var being Set.
Also why goto :eof?
I take the liberty of reposting the OPs requirement with correction to typos.
i need to write a batch script that reads the first line from a txt file (try.txt) and then take the first word from this line and finally copy the try.txt to another directory with the new name file (the first word from the first line )!
I take the italicised to mean that the entire first line of the text file need not be read, only the first word of the first line of the text file need be extracted in order to produce the destination file-name.
I also find that as you've added Echo to the Copy command line that's exactly what is done. After the path is added the displayed output from your script is:
copy try.txt d:\temp\carpatia.txt
(carpatia being the first word of the first line of the junk Try.txt file I created).
so Try.txt doesn't get copied to it's new location with its new file-name.
Have I had a blonde-out?