views:

1019

answers:

1

Hi,

I want to search a file in the current directory from which the batch is running, append the filename to the directory and include that entire directory as part of command that.

So.....

Directory:
C:\tempfiles\batch

Files in C:\tempfiles\batch tmp1.txt tmp2.txt tmp3.txt anyname.exe

I want the batch file, run from the directory, to find any .exe file and append it to the directory name, and use that new string as part of a command to copy the .exe file over to another directory. The command will eventually read like this (the FILETRANSFERSW.exe is the file transfer software that is also in the directory):

C:\tempfiled\batch> FILETRANSFERSW.exe "%CD%\tmp4.exe" X:\dest

The .exe file name will be changing so i need to dynamically add the new filename into the above command everytime i run the batch file. Any ideas??

A: 

If I read your problem correctly, is it sufficient to use the "for" keyword?

for %a in (*.exe) do FILETRANSFERSW.exe %a X:\dest

You can test the output with something innocuous like:

for %a in (*.exe) do echo [[%a]]

%a ends up iterating over *.exe in the current directory, returning the full file name for each one.

JMD
OK, JMD....disregard my last comment....your answer worked like a charm. THANKSSSS!!!!!!!!!