In a Windows OS and using batch file commands, how can I program a script to copy a file into a directory location that changes with unpredictable version numbers?
Say today I have this C:\Program Files\SomeProgram\Proggy5.4.243\,
But tomorrow it might be C:\Program Files\SomeProgram\Proggy5.4.252\
Presuming the process removes the old one (which it does), I am able to write this command to find the current location:
dir "c:\Program Files\SomeProgram\Proggy*" /b
and today that produces:
C:\Program Files\SomeProgram\Proggy5.4.243\
Now I need to use that to copy a file into that location. How is that done?
Forloop with the/Foption can be used with yourDircommand to propagate a variable with your required directory name. For example:@For /F "Delims=" %%G In ('Dir "%ProgramFiles%\SomeProgram\Proggy*" /A:D /B 2^>NUL') Do @Copy "S:\ome\file.ext" "%%G" /Y. To learn more, please see the output from each offor /?,dir /?, andcopy /?whenEntered in a Command Prompt window.