our requirement copy files source destination folder.
the clause during first run of script should copied in subsequent runs should copy files have not been copied till yet , new ones.
the issue destination folder have script works on files , remove them once executed. dont want duplicate files source copied destination.
example
source-> abc.txt,def.xt
after 1strun
dest->abc.txt,def.txt
subsequent runs
source->abc.txt,def.xt, ghi.txt dest->abc.txt,def.xt, ghi.txt
now when script has worked on dest folder , removed abc.txt
, ghi.txt
logic should be
source->abc.txt,def.xt, ghi.txt,jkl.txt
now when script runs should copy new files
dest->ghi.txt, jkl.txt
i thinking if can log output after script run first time txt file , put condition check in log file if text file there before copying source folder destination .
hope able explain.
thx
you copy files not in history this:
$sourcefolder = "..." $destfolder = "..." $historyfile = "history.txt" $recurse = $false $history = get-content $historyfile get-childitem $sourcefolder -recurse:$recurse | ? { -not $_.psiscontainer -and $history -notcontains $_.fullname } | % { copy-item $_.fullname $destfolder $_.fullname >> $historyfile }
the line $_.fullname >> $historyfile
appends copied files history file.
Comments
Post a Comment