# dos wildcard in directory path



## confuseis (Mar 15, 2011)

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. I know i cant do this directly but perhaps theres a trick?

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


----------



## Squashman (Apr 14, 2005)

I don't know how you are possibly going to do this.

How is anyone suppose to determine which of these folder to copy to:

c:\application\random1\folder three
c:\application\random2\folder three
c:\application\random3\folder three

I now have 3 options to copy the files to. There has to be some criteria for selecting which folder to copy them to.


----------



## confuseis (Mar 15, 2011)

Just in case anyone is following this I have put in where I am at so far, This is how we accomplish the task.

for /r "c:\applications" %a in ("folder three") do @if exist %a copy c:\temp\*.* "%a"

If anyone needs any pointers in understanding this let me know.


----------



## Squashman (Apr 14, 2005)

As long as their is one folder named "Folder three" within that folder structure it will work just fine but you never specified that. You made it sound like there could be multiple folders named Folder Three and you needed some way to pick the correct one to copy to which is why I put the example above and you never came back and clarified that.


----------



## confuseis (Mar 15, 2011)

Yes I see what you mean now squashman, given a circumstance like that I suppose I would have to write one file in folder three that i know exists and use the "if exist" command to see if the file within "folder three" is there and only then begin copying. This way we could differentiate betwen folders with the same name. In that hypothetical scenario.


----------

