简体   繁体   中英

Setting svn propset keywords for multiple files

I have to set svn:keywords by svn propset on more than 9000 files. My first idea was using a for-loop to call svn propset every time. The problem is: This is really really really slow. The OS has to create a process for every file. I want to prevent this.

So, my second idea was to give the svn command a file contains the file names. But SVN does not take this.

I am using a powershell script to get all files. My third idea was to use pipes or redirect the output of one file/command as input of the other. But this doesn't work either.

$fileList = "fileList.txt"
Out-File -filePath $fileList -inputObject ""
$files = Get-ChildItem . -recurse -include *.java,*.xml,*.properties,*.sql,*.ps1,*.bat | Where-Object {!($_.psIsContainer)}
foreach($file in $files) {
    Out-File -filePath $fileList -inputObject $file.fullname -append
}
Write-Host "Alle Dateien gefunden. Setze jetzt die SVN Property."
svn propset svn:keywords "LastChangedDate LastChangedRevision LastChangedBy Id HeadURL Revision Author Date"<$fileList

My last idea was to create a ONE STRING with all files. But all file names (with absolute path) take about 1,2 million characters. I tried it, but it already failed to haven't enough free space.

What can I do now? SVN propset has a parameter "--targest" but this won't work. I don't know why.

Greets,

Burak

If it will take multiple files in a single string, but can't handle them all at once, you can user the -ReadCount parameter of Get-Content to break them up into managable batches.

Get-Content $filelist -ReadCount 100 |
 foreach-object {
                 $filebatch = $_ -join ','
                }

Will read in 100 filenames at a time, joining them into a comma separated list, then you can foreach through those batches.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM