2013-01-14 21 views
5

मेरे पास निम्न कोड है जो दो फ़ोल्डर्स की तुलना करता है और फ़ाइलों को प्रत्येक फ़ोल्डर के संबंध में अलग करता है, क्या सबफ़ोल्डर में फ़ाइलों के लिए पूर्ण फ़ाइल/फ़ोल्डर पथ आउटपुट करने का कोई तरीका है? इसके माध्यम से ForEach {$_.InputObject.FullName}पावरहेल - फ़ोल्डर सामग्री की तुलना करें

Compare-Object -ReferenceObject $FolderA -DifferenceObject $FolderB -Passthru | % {$_.FullName} >> C:\CmpOut.txt 

उत्तर

3

इस प्रयास करें:

Compare-Object -ReferenceObject $FolderA -DifferenceObject $FolderB | 
select @{n="InputObject";e={ 
    if ($_.inputobject -is [system.io.directoryinfo]) 
    {([system.io.DirectoryInfo]$_.InputObject).fullname} 
     else 
     { ([system.io.FileInfo]$_.InputObject).fullname}}},SideIndicator 
5

तो जैसे comapre-वस्तु की passthru ध्वज का उपयोग करें।

इस तरह:

Compare-Object -ReferenceObject $FolderA -DifferenceObject $FolderB | ForEach {$_.InputObject.FullName} 
+0

इस तरह SideIndicator में खो दिया है। –

1

पाइप:

चीयर्स

# Create varaibles to store folder paths - pass to Strings... 
param([string]$argFolderA,[string]$argFolderB) 

# Set variables for folder 
$FolderA = Get-ChildItem -Recurse -path $argFolderA 
$FolderB = Get-ChildItem -Recurse -path $argFolderB 

# Compare the contents and output the files different within each folder. 
Compare-Object -ReferenceObject $FolderA -DifferenceObject $FolderB >> C:\CmpOut.txt 
+0

इस तरह साइड इंडिकेटर खो गया है। –

+1

यह खोया नहीं गया है ... यह '$ _। साइड इंडिकेटर 'के माध्यम से उपलब्ध है। – aphoria

 संबंधित मुद्दे

  • कोई संबंधित समस्या नहीं^_^