AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 31594
In Process
user12843
user12843
Asked: 2011-03-23 20:03:38 +0800 CST2011-03-23 20:03:38 +0800 CST 2011-03-23 20:03:38 +0800 CST

文件夹标记?

  • 772

有没有可以标记文件夹的程序?我在一个文件夹中有不同的文件,并且有很多文件夹,如果我可以标记每个文件夹(与标记每个文件相反),那么我很容易对这些文件夹进行分类。有谁知道这样的事情是否可以做到?谢谢你。

folder
  • 3 3 个回答
  • 2907 Views

3 个回答

  • Voted
  1. Peter.O
    2011-03-24T04:42:26+08:002011-03-24T04:42:26+08:00

    这是一个很好的问题,我也在寻找类似的东西,但我很确定 Nautilus 中没有类似的东西,

    但是,如果您可以着手编写一些脚本,则可以相对轻松地调整 Nautilusfile Notes来执行类似的操作。它需要一些基本的(+?)脚本..

    您可以将file Notes注释添加到目录和文件中。

    在 Notes 中搜索您的特定标签将是一件简单的事情,然后在“Notes”中使用匹配的标签创建指向每个目录的临时链接(或永久链接)......然后将这些链接放入“搜索”结果的目录...然后您将在 Nautilus 窗口中显示它!...

    如果我有空闲时间,我会自己做,但是,这是我编写的用于访问、编写和删除 Nautilus Notes 的脚本。它没有执行我上面描述的操作,但它确实显示了如何访问Notes 数据缓存。该脚本旨在供以下人员使用nautilus-actions

    该脚本位于pastbin.ubuntu.com


    更新:我现在已经编写了一个使用上述链接的工作脚本。但是,我现在已经交换了“nautilus Notes”的想法,而是移植到用户未知的.tag 文件中。(所以,如果你喜欢这个脚本,请记住 .tag 的想法是“用户未知”) ..
    我喜欢纯文本文件(它们简单、通用且易于使用)
    我用作locate搜索工具,因为它超快,但它是仅与最后一次运行一样最新updatedb(通常每天运行一次,但您可以随时运行)。

    我试图在评论中解释脚本的用法,但我应该指出它没有经过全面测试,所以它可能在一些小问题上表现不佳。
    它删除/删除的唯一内容是临时目录和任何软链接它包含... 请注意,删除软链接不会删除目标/数据目录。

    这是脚本

    UPDATE2:(修复了一个错误。它只处理前 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
    #
    
    • 4
  2. user unknown
    2011-03-23T23:20:05+08:002011-03-23T23:20:05+08:00

    您可以添加一个文件,如

    .tag
    

    进入每个文件夹。在那里,您可以将信息存储为文本。您可以稍后浏览它们以获取信息。

    也许您更适合使用find之类的工具。

    随意询问它的用法。

    • 3
  3. Enoch Root
    2011-05-19T12:06:02+08:002011-05-19T12:06:02+08:00

    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 并不是那么糟糕。

    • 2

相关问题

  • Virtualbox 中的共享文件夹

  • 如果空的“lost+found”文件夹为空,则自动删除它

  • 更改文件夹权限和所有权

  • 如何更改“地点”菜单中的文件夹图标?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    我需要什么命令来解压缩/提取 .tar.gz 文件?

    • 8 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Marko Smith

    如何使用命令行将用户添加为新的 sudoer?

    • 7 个回答
  • Marko Smith

    更改文件夹权限和所有权

    • 9 个回答
  • Martin Hope
    EmmyS 我需要什么命令来解压缩/提取 .tar.gz 文件? 2011-02-09 14:50:41 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve