How to Use the Command 'jdupes' (with Examples)

How to Use the Command 'jdupes' (with Examples)

The jdupes command is a powerful utility for finding and managing duplicate files on your system. It’s an enhanced fork of fdupes that offers greater performance and more features. By identifying duplicate files, you can free up disk space and organize your file system more efficiently. jdupes can be used in various ways, depending on your specific needs, including searching a single directory, multiple directories, or recursively searching directories while giving users options to delete or preserve files. Below are practical examples demonstrating its use:

Use case 1: Search a single directory for duplicate files

Code:

jdupes path/to/directory

Motivation:

You might want to find duplicate files within a specific directory to free up space or to better organize your file system. By identifying these duplicates, you can decide which files to keep and which to delete.

Explanation:

  • jdupes: Invokes the duplicate file finder command.
  • path/to/directory: Specifies the path to the directory you wish to search. No additional options mean only this directory is searched non-recursively.

Example Output:

Scanning: 100 files, 1 dirs (in memory)
Examining files in path/to/directory
260,953,133                                                                                                                                                
path/to/directory/file1.txt                                                                                               
path/to/directory/duplicate_file1.txt                                                                                    

Use case 2: Search multiple directories for duplicate files

Code:

jdupes directory1 directory2

Motivation:

Sometimes, you need to verify the integrity between two directories—perhaps for a backup verification or merging content. Searching for duplicates in multiple directories helps ensure that no file is unnecessarily occupying space in more than one location.

Explanation:

  • jdupes: The command invoked for finding duplicates.
  • directory1 directory2: Lists the paths of directories to be examined. It correlates files from these locations to find duplicates between them.

Example Output:

Scanning: 150 files, 2 dirs (in memory)
Examining files in directory1
Examining files in directory2
496,574,128                                                                                                                                                
directory1/sample.pdf                                                                                                    
directory2/sample.pdf                                                                                                    

Use case 3: Search all directories recursively

Code:

jdupes --recurse path/to/directory

Motivation:

This use case is particularly useful when you suspect there may be duplicate files hidden deep within a directory tree. By searching recursively, you capture duplicates spread across all subdirectories, making this an efficient way to identify overlapping files throughout a project or storage area.

Explanation:

  • jdupes: The executable.
  • --recurse: Tells jdupes to perform a recursive search, including all subdirectories.
  • path/to/directory: Specifies the starting directory for the recursive search.

Example Output:

Scanning recursively from: path/to/directory
Found 300 files, 50 directories
700,435,210                                                                                                                              
path/to/directory1/fileA.mp3                                                                                                         
path/to/directory1/folderA/fileA.mp3                                                                                                 

Use case 4: Search directory recursively and let user choose files to preserve

Code:

jdupes --delete --recurse path/to/directory

Motivation:

When disk space is limited, you might decide to remove duplicate files but want to control which files remain. This command allows you to search recursively and then interactively choose which duplicates to delete, affording you the chance to preserve important file versions.

Explanation:

  • jdupes: Executes the search.
  • --delete: Initiates the deletion process for found duplicates, enabling a prompt for user selection.
  • --recurse: Ensures the search includes all nested directories.
  • path/to/directory: Target directory where the recursive check begins.

Example Output:

Scanning recursively from: path/to/directory
Found duplicate(s):
300,123,456                                                                                                                                                
path/to/directory/fileB.jpg                                                                                                    
path/to/directory/subfolder/fileB.jpg                                                                             

Delete any of the files above? [ynq] n

Use case 5: Search multiple directories and follow subdirectories under directory2, not directory1

Code:

jdupes directory1 --recurse: directory2

Motivation:

In certain scenarios, you might want to control recursion to only specific directories. This can be particularly helpful if one directory contains organized folders worth preserving as a hierarchy, while another might be less critical to delve into.

Explanation:

  • jdupes: Command execution.
  • directory1: The first directory searched, non-recursive unless specified.
  • --recurse:: Indicates the next directory is to be searched recursively.
  • directory2: This path is processed with recursion, unlike directory1.

Example Output:

Scanning: 200 files, 5 dirs (in memory)
Examining files in directory1
Examining files in directory2 and subfolders
800,900,210                                                                                                                                                
directory2/folderC/fileC.mov                                                                                              
directory2/folderD/folderE/fileC.mov                                    

Use case 6: Search multiple directories and keep the directory order in result

Code:

jdupes -O directory1 directory2 directory3

Motivation:

To maintain clarity in output, especially when checking directories with similar content, it might be desirable to preserve the order in which directories are processed and displayed. This allows better understanding and correlation of the results.

Explanation:

  • jdupes: Initiates search for duplicates.
  • -O: Ensures the search respects the order of directories listed.
  • directory1 directory2 directory3: Specifies paths where duplicates are sought, maintaining listed order in results.

Example Output:

Scanning in directory order: directory1, directory2, directory3
Found duplicate(s):
930,104,266                                                                                                                                                
directory1/imgA.png                                                                                                        
directory3/imgA.png  

Conclusion:

The jdupes command offers a robust solution for managing duplicate files across systems, providing flexibility through various flags to tailor its behavior according to your needs. Whether managing storage efficiency or ensuring file integrity across directories, jdupes stands as a valuable tool in any system administrator’s arsenal.

Related Posts

How to Convert PBM Images to YBM Format Using 'pbmtoybm' (with examples)

How to Convert PBM Images to YBM Format Using 'pbmtoybm' (with examples)

The pbmtoybm command is a utility from the Netpbm suite that allows users to convert Portable Bitmap (PBM) files into Bennet Yee “face” format (YBM) files.

Read More
How to Use the Command 'v4l2-ctl' (with Examples)

How to Use the Command 'v4l2-ctl' (with Examples)

The v4l2-ctl command is a versatile tool used for controlling video devices on Linux systems.

Read More
How to use the command 'xsp' (with examples)

How to use the command 'xsp' (with examples)

The xsp command is a lightweight web server implemented by Mono, an open-source implementation of Microsoft’s .

Read More