Command Line Options
Duplicate File Detective provides a command-line interface that you can use to schedule project execution or integrate with an existing file management process.
Command line instructions (known as arguments) are passed in using a specific syntax which must be followed carefully. Here's an example:
dfd.exe /project:"c:\temp\test-project.dfd" /html:"c:\temp\export.html" /exit
Note that the arguments passed to the command line actions are surrounded by quotes; this is a requirement, as it allows the argument to contain spaces and still be parsed correctly.
You can also access the Duplicate File Detective executable using an absolute path, which is generally what you'll want to do when creating batch files, etc. Example:
"C:\Program Files\Duplicate File Detective\dfd.exe" /project:"c:\temp\test-project.dfd" /exit
Notice how, in the example above, the path to the Duplicate File Detective executable is also contained in quotes. This helps to ensure that spaces in the path name are handled correctly by the Windows command interpreter.
Now a more complex example using some of the various project override options (discussed further below):
dfd.exe /project:"c:\temp\test-project.dfd" /csv:"c:\dupes.csv" /date /SkipZeroLengthFiles:"1" /MatchFileNames:"1" /MatchExts:"1" /MatchContents:"1" /HashZipFileContents:"1" /MatchHashType:"SHA1" /exit
Important: Use of command line options within Duplicate File Detective is project-oriented. You execute a project by providing its name to the Duplicate File Detective program executable. You must create and save a project to disk before you can execute it in this fashion. This is a very powerful concept which effectively provides you with access to every project setting from the command line.
Duplicate File Detective will terminate automatically after processing command line options. No switch is required for this purpose. This happens whatever the outcome of the run: if the project cannot be loaded, or the search is cancelled or fails, the program still writes its event log (see "/SaveEvents" below) and closes rather than remaining open. Pass "/NoExit" if you would rather it stayed open with the results loaded.
Available Command Line Switches
Core switches:
- /Project - Provides the full path to the Duplicate File Detective project file to execute. This flag is required; without it, all other command line options are ignored.
- /Date - Appends the current date to the specified export filename; this applies only when using the "/html", "/csv", or "/xml" flags. Allows for unique daily export filenames within the same parent folder.
- /SaveEvents - Specify a fully qualified text file path to which events will be logged.
- /LoadSettings - Specify the fully qualified path to a program settings file (see About Settings for details).
- /NoExit - Leaves Duplicate File Detective open once the run has finished, instead of closing automatically. Useful when you want to review the results of a command line project by hand. Do not use this switch in a scheduled task: the task is not finished until the process closes, and Windows will skip subsequent runs of a task that is still considered to be running.
- /Exit - Closes Duplicate File Detective when the run has finished. Retained for compatibility with existing batch files and scheduled tasks; it is no longer needed, as this is the default behavior.
Export switches:
- /HTML - Exports the duplicate file results in HTML format when project execution completes.
- /CSV - Exports the duplicate file results in CSV (comma separated values) format when project execution completes.
- /XML - Exports the duplicate file results in XML format when project execution completes.
- /PDF - Exports the duplicate file results in PDF format when project execution completes.
- /XLSX - Exports the duplicate file results in MS Excel format when project execution completes.
- /Email - Emails the export file to one or more recipient addresses (separated by commas).
A wide range of project override switches are also available. These switches override the values contained in the project file you pass in via the "project" parameter (see above).
Project path overrides:
- /Search - Specify one or more search (folder) paths (separated by pipe symbols) that will overwrite those contained in the project.
- /AddSearch - Appends one or more search (folder) paths (separated by pipe symbols) to those currently defined by the project.
- /Exclude - Specify one or more exclusionary (folder) paths (separated by pipe symbols) that will overwrite those contained in the project.
- /AddExclude - Appends one or more exclusionary (folder) paths (separated by pipe symbols) to those currently defined by the project.
Search filter override syntax:
- /SearchMask:"mask"
- /MasksCaseSensitive:[1|0]
- /MasksCompareFullPath:[1|0]
- /SearchSystemFolders:[1|0]
- /SearchHiddenFilesFolders:[1|0]
- /SkipZeroLengthFiles:[1|0]
- /SearchSubFolders:[1|0]
- /NameLenCountFullPath:[1|0]
- /UseRegex:[1|0]
- /ExcludeProtected:[1|0]
- /SizeMatchType:[none|small|medium|large|atleast|atmost|between]
- /FileSizeKb:[numeric]
- /FileSizeKbUpper:[numeric]
- /DateMatchType:[none|week|month|year|lastmod|created|accessed]
- /FromDate:"12/25/2016" - may also include a time, e.g. "12/25/2016 08:30".
- /ToDate:"12/26/2016" - may also include a time, e.g. "12/26/2016 17:00".
- /FromTime:"12/25/2016 08:30" - an alternate name for "/FromDate"; the two are interchangeable.
- /ToTime:"12/26/2016 17:00" - an alternate name for "/ToDate"; the two are interchangeable.
- /NameLenMatchType:[none|greater|less|equal|between]
- /NameLenLower:[numeric]
- /NameLenUpper:[numeric]
Comparison option override syntax:
- /MatchFileNames:[1|0]
- /MatchExts:[1|0]
- /MatchFileSizes:[1|0]
- /MatchLastMod:[1|0]
- /MatchContents:[1|0]
- /MatchBytes:[1|0]
- /MatchHashType:[CRC32|ADLER32|MD5|SHA1|SHA256|SHA512]
- /NormalizeFileNames:[1|0]
- /SkipNumbersInFileNames:[1|0]
- /IgnoreCopyPatterns:[1|0] - ignores copy and version decorations in file names, such as "- Copy", "(2)", and "Copy of".
- /FileNameCompareMode:[0|1|2|3|4]
- /NameMatchCount:[numeric]
- /IgnoreTimes:[1|0]
- /IgnoreSeconds:[1|0]
- /MatchMusicTags:[1|0]
- /MusicTagsToMatch:[title|artist|album|track|year|genre|duration|bitrate]
- /AlwaysExtractMusicTags:[1|0]
- /EmptyMusicTagOption:[0|1]
- /MatchImageMetadata:[1|0]
- /ImageTagsToMatch:[numeric]
- /MatchDocProperties:[1|0]
- /DocTagsToMatch:[numeric]
- /HashZipFileContents:[1|0]
- /HashZipFilePwd:"password"
- /MatchParentFolders:[1|0]
- /MatchParentFolderDepth:[numeric]
Numeric Comparison Option Values
Most comparison options are simple on/off switches. The handful listed below take a number instead, because the corresponding project setting is either a choice among several or a count. Each one mirrors a control in the Comparison Options dialog, and the value you pass is the same value the project file stores.
/FileNameCompareMode - selects how much of the file name takes part in the comparison. Applies only when "/MatchFileNames" is enabled:
- 0 - Compare all file name characters (the default).
- 1 - Compare only characters at the start of the file name. Use "/NameMatchCount" to say how many.
- 2 - Compare only characters at the end of the file name. Use "/NameMatchCount" to say how many.
- 3 - Ignore characters at the end of the file name. Use "/NameMatchCount" to say how many.
- 4 - Compare file name words in any order.
/NameMatchCount - the number of file name characters used by modes 1, 2, and 3 above. Accepts 1 through 255; it has no effect in modes 0 and 4.
/EmptyMusicTagOption - controls what happens when a music tag being compared is empty. Applies only when "/MatchMusicTags" is enabled:
- 0 - Don't fail the comparison if at least one other non-empty tag matches.
- 1 - Always fail the comparison; tags must have values (the default).
/ImageTagsToMatch - selects which pieces of image metadata are compared. Applies only when "/MatchImageMetadata" is enabled. Add the values together to select more than one - for example, "/ImageTagsToMatch:6" compares camera make and model:
- 1 - Date taken
- 2 - Camera make
- 4 - Camera model
- 8 - Dimensions
- 15 - All of the above
/DocTagsToMatch - selects which document properties are compared. Applies only when "/MatchDocProperties" is enabled. Add the values together to select more than one - for example, "/DocTagsToMatch:3" compares title and subject:
- 1 - Title
- 2 - Subject
- 4 - Page count
- 8 - Word count
- 16 - Character count
- 32 - PDF document ID
- 64 - Embedded creation date
- 127 - All of the above
/MatchParentFolderDepth - how many levels of parent folder must match, counting back from the folder each file sits in. Applies only when "/MatchParentFolders" is enabled. Accepts 1 through 99; the default is 1, and values below 1 are treated as 1:
- 1 - Files match only when the name of the folder containing them is the same. "C:\Backup\2019\Photos" and "D:\Archive\Photos" both end in "Photos", so they match.
- 2 - The last two folder names must match. Using the same example, "2019\Photos" and "Archive\Photos" differ, so those files no longer match.
Higher values compare correspondingly more of the path. Only the trailing portion of each parent folder path is compared, never the drive or the full path.
Tip: To schedule the execution of a Duplicate File Detective project, first create a batch (.bat) file that calls the Duplicate File Detective executable with the correct command line arguments. Then use the integrated Windows scheduler to invoke the batch file on a scheduled basis.