Solução de script bash
@Rmano me bateu, mas acho que é sempre bom ter soluções diferentes. Aqui está o script que compus:
#!/bin/bash
# NAME: recoll_move_results
# VERSION: 0.1
# AUTHOR: (c) 2014 Glutanimate
# DESCRIPTION: queries recoll database for provided string and either symlinks or moves
# results
# DEPENDENCIES: recoll
#
# LICENSE: GNU GPLv3 (http://www.gnu.de/documents/gpl-3.0.en.html)
#
# NOTICE: THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
# EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
# PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR
# IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
# PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE,
# YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
#
# IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY
# COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS
# PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
# INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
# THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED
# INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE
# PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
# PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
#
# USAGE: recoll_move_results <query>
# VARIABLES / SETINGS
DESTINATION="$HOME/recollresults" # ⇐ Set the destination folder here
QUERY="$@"
USAGE="$0 <query>"
if [[ -z "$QUERY" ]]
then
echo "Error: No arguments provided."
echo "Usage: $USAGE"
exit 1
fi
# create destination folder
mkdir -p "$DESTINATION"
# FUNCTIONS
# query recoll and convert URIs to file paths
recoll_get_results(){
recoll -t -b "$QUERY" 2> /dev/null | sed 's,file://,,g'
}
# symlink or move files read from stdin
move_files(){
while read -r FILE; do
echo "Processing $FILE"
FILENAME="${FILE##*/}"
# PLEASE USE ONLY ONE OF THE OPTIONS BELOW. COMMENT THE ONE YOU DON'T WANT
# AND UNCOMMENT THE ONE YOU DO WANT
ln -sv "$FILE" "$DESTINATION/$FILENAME" # Create a symbolic link in $DESTINATION
#mv -v "$FILE" "$DESTINATION/$FILENAME" # Move to $DESTINATION
done
}
# MAIN
recoll_get_results "$QUERY" | move_files
Uso
Use o script com:
recoll_move_results <query>
Ele executará a consulta fornecida e um link simbólico ou moverá todos os resultados da pesquisa para uma pasta recém-criada. Espaços e caracteres especiais (além das novas linhas) devem ser manipulados corretamente pelo script.
Configurações
Aqui estão algumas configurações que você pode personalizar:
-
DESTINATION="$HOME/recollresults"
- modifique isso para definir a pasta de destino
-
ln -sv "$FILE" "$DESTINATION/$FILENAME"
- comente esta linha (com #
) e descomente a seguinte se tiver certeza de que deseja mover os arquivos em vez de criar links simbólicos para eles
Por favor, note que mover os resultados impossibilitará o acesso aos arquivos da interface de pesquisa do Recoll até que você atualize o índice novamente.
Outra opção seria copiar os arquivos substituindo:
'ln -sv "$FILE" "$DESTINATION/$FILENAME"'
com
'cp -v "$FILE" "$DESTINATION/$FILENAME"'