Locating local directory with help from Regex


hi all, need copy number of directories 1 location on local server.  in order facilitate install of language packs have job copied them locally.  local path source install contained in var.  have array of individual language packs need installing, i.e. “ar”, “bg”, “da”, “en”, etc

the actual format of directories need copy set of 4 digits, i.e. 1031,1036,1041,3082,1025,1026,1027, etc.  source of hoping locate using get-childitem , regex.

so far have created foreach loop struggling get-childitem , regex part of being incredible noob am.

  foreach ($language in $languages)
  {
    $languagepath = "$languagepacksdirectory\$language"  #  i.e.  “c:\documents , settings\administrator.ccsvpriv7\local settings\temp\languagepacksp264bitedition\bg”

    # source directory
    $directorysource = (get-childitem("$languagepath"regex(???)) # not sure needs go here???
   
    # copy template files directory destination
    if (!(test-path $directorysource)){throw "path not exist: [$directorysource]"}
    $destination = "$destinationpath\$language\xml"
    if ((test-path $destination))
    {
      copy-item -path "$directorysource -destination "$destination\" -force -recurse -verbose
    }
  }

any appreciated.

 


thanks, -ja

im not sure follow you. have set of languages culture code (bg example) , each language want copy correct package, number code. information associates these 2 things?

so example, dir of $languagepath you? contain file/folder culture code?

so lets there file/folder 4 digit code in $languagepath, it

dir -path $languagepath | {$_.name -match "\d{4}")

that work provided there 1 4 digit name in there... otherwise return multiples , there more work involed.



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

some help on Event 540

WMI Repository 4GB limit - Win 2003 Ent Question

Event ID 1302 (error 1307) DFS replication service encountered an error while writing to the debug log file