0

I have a batch script dilemma with copying directory structures to alternative locations. We have defined five digit numerals for the main name of a Dir but there is also a varying description, is there any way I can wildcard the description in my copyto path e.g.

xcopy <path>Template <path>09999_ParentFolder\<new name> \e

The "ParentFolder" is an unknown and may contain spaces, I haven't had any luck with '*'. I want to avoid asking users to type in the exact details if possible, my only other idea is if I can create a selection list of a dir that the user could enter via a numbered selection?

khellang
  • 17,550
  • 6
  • 64
  • 84
CAD-wiz
  • 39
  • 1
  • 7
  • Something says wildcards wouldn't (shouldn't ?) work with target locations in a copy operation... – vaisakh Feb 18 '13 at 13:36
  • Agreed, if I could avoid Dirs with descriptions life would be so much easier! – CAD-wiz Feb 18 '13 at 13:37
  • Looking at this another way. I already have vars set for the directory number %jobn% which will be unique is there a way I can search for the unknown element to add to another variable, I know on the command line I can Dir 09999* and I will get a single report with the full name, can this be collected somehow to a named variable? – CAD-wiz Feb 18 '13 at 14:22
  • Try something like. `for /f "delims=" %%A in ('dir /a:d /b %jobn%*') do if exist "%%~fA echo %%~fA"` or `for /d %%A in ("%jobn%*") do echo %%~fA` just change the echo to set commands. – David Ruhmann Feb 18 '13 at 16:52

1 Answers1

0

List a directory folder to a variable

I found the solution to this from my other posting (see link), thanks for your help. :)

Community
  • 1
  • 1
CAD-wiz
  • 39
  • 1
  • 7