Robocopy: Copying files from variable source -


i'm trying copy specific folder w/ files network drive using robocopy. catch is, files want copy updated often, , placed in folders version-numbers. possible use robocopy grab files whatever folder has highest number?

ex: source path looks this: k:\program\versions\6.7.0.144\ '144' being number changed often. path k:\program\versions\ contains versions, each in own folder, so: http://i.stack.imgur.com/zdl16.png

so, each time run script, want files latest version/highest number.

so far, script looks this:

robocopy \\k:\program\versions\6.7.0.*\bin\config c:\target /e /z /a-:r 

robocopy not accept * in source-path. so, possible robocopy, or have use different approach?

you cannot robocopy alone. have script bit. assuming first versions zeroed (like 6.7.001), easy highest version number requested.

i provide below snippets batch & powershell.

batch:

set srcpath=k:\program\versions /f %%f in ('dir /b /ad /o-n %srcpath%') set srcver=%%f & goto next :next echo # version %srcver% used robocopy %srcpath%\%srcver%\bin\config c:\target /e /z /a-:r /log:c:\backup.log 

goto next break loop after first element, since sorted name, descending

powershell:

$srcpath = "k:\program\versions" $srcpath = "d:\temp" $srcver = (get-childitem $srcpath | where-object { $_.psiscontainer } | sort-object -property name -descending | select-object -first 1).fullname $srcfull= $srcver + '\bin\config' echo "# version $srcver used" & robocopy $srcfull c:\target /e /z /a-:r /log:c:\backup.log 

hth


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -