No announcement yet.

wildcard in directory path

  • Filter
  • Time
  • Show
Clear All
new posts

  • wildcard in directory path

    Hi All

    I need to use a wildcard in a directory path as one folder within the directory may change. Im using this to backup a folder on our network.

    e.g. copy c:\temp c:\application\random directory\folder three

    random directory is where the magic needs to happen. I need to copy files from temp to folder three no matter which directories separate them.

    Any one one in the know???

    Thanks for reading

  • #2
    Re: wildcard in directory path

    I don't think that will be possible unless the application you are using can "scan"
    through the second level folders.

    Maybe you can write some type of vbscript that your backup software can call and pass the third level folder to it, then the vbscript would have to check all second level folders looking for the third level.
    JM @ IT Training & Consulting


    • #3
      Re: wildcard in directory path

      Yeah I read you cant do this directly and I thought there may be some trick using variables etc.

      Im just learning batch and dont have the time to learn anything else like vb ps etc.


      • #4
        Re: wildcard in directory path

        @echo off
        Set "parent=c:\application"
        SET "target="
        For /f "tokens=*" %%! in (
           'dir /AD /B "%parent%"') do (
           if exist "%parent%\%%!\folder three" (
           SET "target=%parent%\%%!\folder three"&goto:defined))
        If not defined target goto:EOF
        echo %target%
        :: copy c:\temp "%target%"
        Last edited by Rems; 29th November 2011, 00:49.

        This posting is provided "AS IS" with no warranties, and confers no rights.


        ** Remember to give credit where credit's due **
        and leave Reputation Points for meaningful posts


        • #5
          Re: wildcard in directory path

          That looks good. Ill muse over that code and absorb it.

          Many thanks