bc3_search.rb

bin/bc3_search.rb
Last Update: 2011-01-30 21:40:02 +0100

Search inside bc3-snapshots.

Please remember: BC3 offers itself a search function.

This bc3_merge may be usefull, if you want to search in many snapshots for specific files or directories.

Usage:

bc3_search.rb 'pattern' *.bcss [options]

The ’ around $pattern are needed, else the shell may expand the pattern as shell glob.

Search is only possible on basenames (no pathes).

Pattern

The search pattern handles the following parameters:

  • * Matches any character
  • ? Matches exactly one character
  • [] and {} may make problems.

The pattern is translated to a regular expression. With option -r the pattern is used as a regular expression, no conversion is made.

Report the Result

YAML-File

Use option -y

BC3-Snapshot

Use option -b (or —bcss) and the search result is saved as a snapshot.

bc_search -b extract *.bcss

Creates snapshots with the search result. The Filename is the original name with an additional ‘extract’”.

bc_search *.bcss -b

Filename will get a “_extract_YYYY-MM-DD-hhmm”. The option -b must be at the end (else the *.bcss will be taken to build a new filename)

Use option -B (or —BCSS) and the global search result is saved as a snapshot.

bc_search -B extract.bcss *.bcss

Creates a snapshot ‘extract.bcss’ with all collected search results.

bc_search *.bcss -B

Filename will get a “bc3_search_YYYY-MM-DD-hhmm.bcss“. The option -B must be at the end (else the *.bcss will be taken to build a new filename)

Duplicates

With option -d (or —duplicates) you can restrict the results on duplicates inside a snapshot.

With option -D (or —Duplicates) you can restrict the results on duplicates in the snapshots. Only files with a duplicate in another (or the same) snapshot are listed.

The duplicate search can be combined with yaml or bcss-option.

BC3 method

Beyond Compare offers itself a way to find duplicates: The only way to find duplicate files is to flatten your folder structure so that all the files appear to be at the same level. You then can enable/show the CRC column, sort by it, then manually scan the file list for files with the same size and CRC code. I wouldn’t advise it for a large number of files and folders, though. It could take a while to calculate all the CRC values, and it would be a tedious process to manually look through them all for duplicates. www.scootersoftware.com/vbulletin/showpost.php?p=27736&postcount=4

Examples:

bc3_search.rb '*.rbw' *.bcss

Search for rbw-files in all snapshots.

duplicate option

bc3_search.rb -d '*' *.bcss
bc3_search.rb --duplicates '*' *.bcss

Search for duplicates inside all snapshots. Use the pattern ’*’ to check all files.

bc3_search.rb -d '*.rb' *.bcss

Search for duplicate ruby scripts in all snapshots.

bc3_search.rb -D '*' *.bcss
bc3_search.rb --Duplicates '*' *.bcss

Search for duplicates inside snapshots. Each snapshot lists all files, where you can find a duplicate in the same or another selected snapshot.

regexp option

bc3_search.rb -r '[ab].*\\.rbw' *.bcss
bc3_search.rb --regexp '[ab].*\\.rbw' *.bcss

Search for rbw-files starting with an a or a b. The option -r switch to regular expression.

yaml option

bc3_search.rb '*.rbw' *.bcss -y
bc3_search.rb '*.rbw' *.bcss -yaml

Search for rbw-files in all snapshots and return the result in a yaml-list.

Required files

  1. optparse
  2. bc3