You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

咨询找出同名不同扩展名的两个文件夹间文件差异并清理多余文件的方法

咨询找出同名不同扩展名的两个文件夹间文件差异并清理多余文件的方法

Hey Adam, I totally get where you’re coming from—WinMerge can feel frustrating when you’re trying to match files by their base names instead of full filenames (extensions included). Let’s go through a few solid solutions that’ll help you track down those missing files and clean up the extras without hassle.

方法一:用PowerShell快速对比(无需额外工具)

Since you’re on Windows, PowerShell is built right in and perfect for this job. Here’s step-by-step how to use it:

  • Open PowerShell and navigate to the parent folder that contains your two photo folders (e.g., if your folders are named JPG_Images and DNG_Images, run cd C:\Path\To\Your\Parent\Folder)
  • First, grab the base filenames (without extensions) from each folder:
    # Get all JPG base names
    $jpgBaseNames = Get-ChildItem .\JPG_Images -Filter *.jpg | ForEach-Object { $_.BaseName }
    # Get all DNG base names
    $dngBaseNames = Get-ChildItem .\DNG_Images -Filter *.dng | ForEach-Object { $_.BaseName }
    
  • Find extra JPGs (files that exist in JPG folder but not in DNG):
    $extraJPGs = $jpgBaseNames | Where-Object { $_ -notin $dngBaseNames }
    # To see full paths of these extras
    $extraJPGs | ForEach-Object { Join-Path .\JPG_Images "$_.jpg" }
    
  • Find extra DNGs (files that exist in DNG folder but not in JPG):
    $extraDNGs = $dngBaseNames | Where-Object { $_ -notin $jpgBaseNames }
    # To see full paths of these extras
    $extraDNGs | ForEach-Object { Join-Path .\DNG_Images "$_.dng" }
    
  • Once you’ve verified the list is correct, delete the extra files (always double-check before deleting!):
    # Delete extra JPGs (add -Confirm to get a prompt for each deletion)
    $extraJPGs | ForEach-Object { Remove-Item (Join-Path .\JPG_Images "$_.jpg") -Confirm }
    # Delete extra DNGs
    $extraDNGs | ForEach-Object { Remove-Item (Join-Path .\DNG_Images "$_.dng") -Confirm }
    

方法二:调整WinMerge设置让它匹配基础文件名

You didn’t get WinMerge working because it defaults to comparing full filenames (including .jpg/.dng). Tweak these settings to fix that:

  • Open WinMerge, go to Tools > Options
  • Switch to the Compare tab
  • Under Filename Filters, click Edit and add two filters: *.jpg and *.dng (make sure both are checked)
  • Back in the Compare tab, look for Compare options and check the box labeled Compare file contents by name only (or similar wording—some versions might call it "Match files by base name")
  • Now when you select your two folders for comparison, WinMerge will pair up files with the same base name and highlight any that are missing from one folder. You can right-click the extra files and select Delete to remove them directly.

方法三:用FreeFileSync(直观的图形化工具)

If command lines feel too technical and WinMerge still isn’t clicking, FreeFileSync is a free, user-friendly tool that handles this scenario perfectly:

  • Download and install FreeFileSync (it’s free for personal use)
  • Add your JPG folder to the left pane and DNG folder to the right pane
  • Go to Settings > Comparison Settings
  • In the File Comparison section, select Compare by file name only and save the settings
  • Click the Compare button—you’ll see a clear list of files that exist in one folder but not the other
  • Use the preview feature to confirm which files are extras, then run the deletion/sync operation to clean them up

备注:内容来源于stack exchange,提问作者Adam

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.22 15:54:35