In my previous post i made a batch (see bellow)
@ECHO OFF
XCOPY "%cd%\CTB\*.CTB" c:\ICT\AutoCAD_2010\CTB\
MSG * 开发者_Go百科Hello %USERNAME%, Your CTB was successfully transferred.
exit
How can i achive a way to have the message display the file name (assuming that the name varries from time to time)
If no one comes up with a more elegant solution, you can always resort to spam :-)
(inside a batch file, you need %%p from the command line %p)
for %%p in (%cd%\CTB\*.CTB) do MSG * Hello %USERNAME%, %%p was copied to C:\ICT\Auto...
For example I used:
C:\Users\Stephen>for %p in ("D:\My Documents\Youcam\*.jpg") do MSG * Stephen %p is here
to spam myself with all the avaialble graphics in that directory.
Since XCOPY
displays the names of the files copied, it is possible to read the output and set an environment variable to the first line (assuming there's always one file to copy):
@ECHO OFF
SET filename=
FOR /F "delims=" %%R IN ('XCOPY "%cd%\CTB\*.CTB" c:\ICT\AutoCAD_2010\CTB\') DO (
IF NOT DEFINED filename SET "filename=%%R"
)
MSG * Hello %USERNAME%, Your "%filename%" was successfully transferred.
EXIT
精彩评论