CD into sub directory without knowing parent

Microsoft Windows xp professional w/serv...
April 9, 2010 at 05:53:56
Specs: Windows XP
Let's say I have a file called file.txt, and I put the most up to date file.txt in c:\fileupdate. Let's then say that there's a certain program that needs a copy of this file.txt in a certain directory.

example:

C:\program\tmp\aaaa9m\redirect\

Let's now say that every time I restart this program, it automatically creates a newer directory under C:\program\tmp\ and sticks a new redirect sub directory under that directory.

example of new directory path: C:\program\tmp\bbbb9m\redirect\

Would it be possible to write a batch file that copies the latest version of file.txt from c:\fileupdate into the latest C:\program\tmp\[random alpha numeric characters]9m\redirect\ directory, no matter what the [random alpha numeric] portion of the path changes to?


See More: CD into sub directory without knowing parent

Report •

#1
April 9, 2010 at 09:15:18
This is not a DOS question but a Programming one that is solved by the following NT batch script:

@echo off
pushd C:\program\tmp
for /F "delims=" %%j in ('dir /B /AD-H /O-D *9m') do (
  copy "C:\fileupdate\file.txt" "%%~fj\redirect" > nul
  echo.  File "file.txt" copied to "%%~fj\redirect"
  goto :DONE
)
:DONE
popd
:: End_Of_Batch


Report •

#2
April 9, 2010 at 11:33:25
Thanks much. That did the trick.

Report •
Related Solutions


Ask Question