有没有可以标记文件夹的程序?我的文件夹中有不同的文件,而且文件夹太多了,如果我可以标记每个文件夹(而不是标记每个文件),那么我就可以很容易地对这些文件夹进行分类。有人知道是否可以这样做吗?谢谢。
答案1
这个问题问得好,我也在寻找类似的东西,但我很确定 Nautilus 中还没有内置类似的东西,
但是如果你能动手编写一些脚本,你就可以相对轻松地让 Nautilusfile Notes
做类似的事情。这需要一些基本的(+?)脚本。
您file Notes
可以将注释添加到目录和文件。
在 Notes 中搜索你的特定内容很简单标签,然后为每个目录创建临时链接(或永久链接)并在“注释”中使用匹配的标签...然后将这些链接放入“搜索结果”目录中...然后您可以在 Nautilus 窗口中显示它!...
如果我有空闲时间,我会自己做,但是,这里是我编写的用于访问、写入和删除 Nautilus Notes 的脚本。它没有执行我上面描述的操作,但它确实显示了如何访问 Notes 数据缓存. 该脚本旨在供nautilus-actions
更新:我现在已经编写了一个使用上述链接的工作脚本。但是,我现在已经交换了“nautilus Notes”的想法,并嫁接了用户未知.tag 文件代替..(因此,如果您喜欢该脚本,请记住 .tag 的想法是“用户未知”)..
我喜欢纯文本文件(它们简单的并且用途广泛,使用起来非常方便)
我一直将locate
其用作搜索工具,因为它速度超快,但它仅与上次运行的一样最新updatedb
(通常是每天,但您可以随时运行它)。
我试图在评论中解释该脚本的用法,但我应该指出它尚未经过全面测试,因此可能会在某些小问题上表现不佳。
它删除/移除的唯一内容是临时目录和它包含的任何软链接...请注意,删除软链接不会删除目标/数据目录。
以下是脚本
更新2:(修复了一个错误..它仅处理前 100 个 .tag 文件)
#!/bin/bash
# Script: dirtags ...(by fred.bear)
#
# Summary: Open the file browser in a temporary directory
# which contains soft-links to directories whose
# '.tag' file contains the search string in $1
#
# .tag files are files you create in any directory which
# you wish to *tag*.
#
# .tag files are simple free form text, so you can
# put anything you like in them...
#
# The script uses `locate` to create a list of .tag file
# 'locate' is very fast, but because it depends on 'updatedb'
# for its list of current files, it can be a bit out of sync
# with a newly added .tag file... Modifying an existing
# .tag file does not effect `locate`
# To refresh the `locate` database, just run 'sudo updatedb'
# .. (updatedb typically auto-runs once a day, but you should check)
#
# Note: The search result soft links are put into a temporary directory
# This directory is removed each time you run the script
# TODO: allow saved searches (?) maybe
#
# Note: With nautilus, running the script a second time while
# the previoulsy opened wiondow is still open, cause the
# second window to open in its parent directory: /tmp/$USER
# ... but you can then just enter the 'dirtags' dir
# you see listed /tmp/$USER/$bname
# TODO: this probably happens because currently the
# directory is being removed each time the script
# is run... (related to "allow saved searches")
#
# A sample usage of this script:
#
# 1. Make a '.tag' file in each of several test directories.
# 2, For this first-time test, run 'sudo updatedb' so that the
# newly added .tag files are added to the 'locate's database
# 3. In each .tag file, put some tags (words or phrases to serch for)
# eg; action comedy drama good bad sci-fi documentary
# 4. Run this script with a single argument.. (a grep regex)
# eg "action|comedy"
#
function args_grep_links {
# $1 -- the grep regex
##echo grep -l '"'$1'"' ${tagged[@]}
< <(eval grep -l '$1' ${tagged[@]}) \
sed "s/^\(.*\)\/\.tag/ln -s \"\1\" $tagdbs/" \
>>"$tagdir"/.tag.slinks
##(gedit "$tagdir"/.tag.slinks &)
# make the soft links
source "$tagdir"/.tag.slinks
rm "$tagdir"/.tag.slinks
unset tagged
aix=
}
# Identity the script
bname="$(basename "$0")"
# Syntax
if [[ "$1" == "" ]] ; then
echo "ERROR: $bname requires one arg; a 'grep' regular expression string"
echo " eg: $bname \"music\" ......... Any instance of \"music\" .....(eg: \"musical\")"
echo " eg: $bname \"\<music\>\" ..... Only the word \"music\" ...(but not \"musical\")"
echo " eg: $bname \"muscic\|action\". Any instance of \"music\" or \"action\")"
exit 1
fi
# 'locate' the .tag files
# =======================
tagdir="/tmp/$USER/$bname"
tagdbs="${tagdir//\//\/}"
[[ -d "$tagdir" ]] && rm -rf "$tagdir" # remove all
[[ ! -d "$tagdir" ]] && mkdir -p "$tagdir" # fresh start
cp /dev/null "$tagdir"/.tag.slinks
unset tagged # array of .tag files
aix=0 # arg index
amax=10 # arg max per call to grep
fct=0 # file count
while IFS= read -r file ; do
tagged[$aix]="$file"
####echo ${tagged[aix]}
((aix++));((fct++))
(( aix == amax )) && args_grep_links "$1"
done < <(locate -ber ^\.tag$ |sed "s/.*/\"&\"/")
(( aix < amax )) && args_grep_links "$1"
sleep 1 # to allow time for rm to settle down after rm and adding links
xdg-open "$tagdir"
exit
#
答案2
答案3
tracker-utils
将为此而努力。
答案尚未被接受,但我发布的示例应该可以让您了解如何使用该程序。标签添加在目录中也能正常工作,我也对其进行了测试。
目录示例
<sean@mymachine:~> tracker-tag -a projects src/ code/ projects/
<sean@mymachine:~> tracker-tag -s projects
Results: 3
/home/sean/projects
/home/sean/src
/home/sean/code
请注意,您需要手动启动 trackerd 才能使 tracker-tag/* 实用程序正常工作:
<sean@mymachine:~> /usr/lib/tracker/trackerd &
您可以使用以下方式配置跟踪器:
<sean@mymachine:~> tracker-preferences
我仍然没有运行跟踪器小程序(在 中列出ps
,但即使在 之后也没有在 nautilus 中显示nautilus -q
),但我并不关心。我大部分时间都不使用 GUI 工具;我更喜欢 CLI,因为它通常比单击东西快得多。
我读了你之前在一篇帖子中的回复,看起来你正在尝试在 Nautilus 中添加/搜索标签,尽管你没有在问题中将其列为主要标准。这是其他人正在做的事情,所以这个答案对你来说可能没用。话虽如此,如果你完成了通常无法在 GUI 中完成的工作,偶尔跳转到 CLI 也不错。