Fast search ‘n sorting on my fileserver

Last Updated or created 2023-01-05

When i’m looking for certain files on my fileserver i sometimes have to fallback to locate.

Most of the times i use the methods mentioned in :
https://www.henriaanstoot.nl/2022/08/04/finding-files-on-my-fileserver/

The script below helps me to copy located files to a temporary directory.
(Which is excluded in al kinds of other find tools)

It will remove the slashes in a path, but keeps the rest.

  • You can pipe to this script
  • All files in 1 directory, but NO overwrite of files (keeps path). This allows for easy browsing with a picture viewer.
  • Want to know original path, look at the filename .. think of where the slashes should go

Example:

Lets find all jpg’s which linux in its name

# this will list all found files
locate -i linux | grep -i jpg$ 

output example (see below) (With slashes and spaces)
/tank/WorkDirectory/TMP/UITZOEKEN/cds uitzoeken/div/141/31/cd3/done/gfx/linux-from-scratch.jpg

cplocatescript

#!/bin/bash
mkdir -p /mnt/private/TEMP/$$
cat - | while read line ; do cp "$line" /mnt/private/TEMP/$$/$(echo "$line" | tr -cd 'A-Za-z0-9._-' ; echo "" ) ;done

When running combined command:

locate -i linux | grep -i jpg$ | cplocatescript

It will create a directory like below

ls /mnt/private/28723/
fileserverHenri__newsort__WorkDirectory2018_ltstufffromlaptopsnew_uitzuitzoekenWERKDIRECTORY-DEC-2010cd6wwwhtdocsworklinux-project14l.jpg
fileserverHenri__newsort__WorkDirectory2018_ltstufffromlaptopsnew_uitzuitzoekenWERKDIRECTORY-DEC-2010cd6wwwhtdocsworklinux-project14s.jpg
tankWorkDirectoryTMPUITZOEKENcds-uitzoekendiv14131cd3donegfxlinux-from-scratch.jpg
tankWorkDirectoryTMPUITZOEKENcds-uitzoekendiv17166dataUNISONBACKUP_TO_HOMEUNISON_DONELINUX_FROM_SCRATCH.JPG
tankWorkDirectoryTMPUITZOEKENcds-uitzoekendiv982datalinux-presentatiespresentatie.hp.nllinux_cd_deel3Imagescdromtitel.jpg
etc ...
etc ...
etc ...
Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *