[Bash] Find Redundant Files Saved by Chrome


Find redundant files saved by Chrome browser via Bash script.

chrome.sh | repository | view raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#!/bin/bash

# $1 is the directory in which files to be processed
IFS=$'\n'
for path in $(find $1 -type f)
do
  filename=$(basename "$path")
  filenameWithoutExt=${filename%.*}
  if [[ ${filenameWithoutExt} =~ \ \([0-9]+\)$ ]]; then
    echo ${path}
    #rm ${path}
  fi
done

Tested on: Ubuntu Linux 16.04, bash 4.3-14ubuntu1.


References:

[1][Python] Find Redundant Files Saved by Chrome
[2][Golang] Find Redundant Files Saved by Chrome
[3]
[4]
[5]bash regex match - Google search