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
Post a Comment