diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..2f8500c5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/bin +/tmsu-* diff --git a/Makefile b/Makefile index 080afa3d..375bf3eb 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ dist: compile cp README.md $(DIST_DIR) cp COPYING.md $(DIST_DIR) @mkdir -p $(DIST_DIR)/bin - cp misc/bin/mount.tmsu $(DIST_DIR)/bin/ + cp misc/bin/* $(DIST_DIR)/bin/ @mkdir -p $(DIST_DIR)/man gzip -fc misc/man/tmsu.1 >$(DIST_DIR)/man/tmsu.1.gz @mkdir -p $(DIST_DIR)/misc/zsh @@ -47,6 +47,8 @@ install: cp bin/tmsu $(INSTALL_DIR) @echo "* Installing 'mount' command support" cp misc/bin/mount.tmsu $(MOUNT_INSTALL_DIR) + @echo "* Installing scripts" + cp misc/bin/tmsu-* $(INSTALL_DIR) @echo "* Installing man page" mkdir -p $(MAN_INSTALL_DIR) gzip -fc misc/man/tmsu.1 >$(MAN_INSTALL_DIR)/tmsu.1.gz diff --git a/README.md b/README.md index cf0127a6..24fda10d 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,12 @@ v0.6 (in development) only a single file argument, which is useful when using xargs. * Replaced 'stats' command with 'info' command (with --stats and --usage options for tag statics and usage counts respectively). + * Included a set of scripts for performing filesystem operations whilst + keeping the TMSU database up to date. If you wish to use these scripts + I recommend you alias them to simpler names, e.g. 'trm'. + - tmsu-rm! Removes files from the filesystem and TMSU + - tmsu-mv! Moves a file in the filesystem and updates TMSU + - tmsu-merge! Merges files (deleting all but the last) v0.5.2 ------ diff --git a/misc/README b/misc/README index 09c21ad5..4e2545a2 100644 --- a/misc/README +++ b/misc/README @@ -1,5 +1,9 @@ -bin Supporting binaries. -db-upgrade Database upgrade scripts. -ebnf Extended Backus-Naur Form file for the TMSU query language. -man Man page. -zsh Command completion for the shell Zsh. +bin Supporting executables + mount.tmsu Support for 'mount' command + tmsu-unsafe-rm Delete a file on the filesystem and remove it from TMSU + tmsu-unsafe-mv Move a file and update the path in TMSU + tmsu-unsafe-mf Merges two files by deleting the first and applying its tags to the second +db-upgrade Database upgrade scripts +ebnf Extended Backus-Naur Form file for the TMSU query language +man Man page +zsh Command completion for the shell Zsh diff --git a/misc/bin/README b/misc/bin/README deleted file mode 100644 index e59777e9..00000000 --- a/misc/bin/README +++ /dev/null @@ -1 +0,0 @@ -mount.tmsu: Helper script so that the TMSU virtual filesystem can be mounted via the Unix 'mount' command. diff --git a/misc/bin/tmsu-fs-merge b/misc/bin/tmsu-fs-merge new file mode 100755 index 00000000..7989fd08 --- /dev/null +++ b/misc/bin/tmsu-fs-merge @@ -0,0 +1,19 @@ +#!/bin/sh + +usage="\ +Merges two or more files + +Each FILE's tags are applied to DESTFILE before being deleted from the filesystem. + +Usage: $0 FILE... DESTFILE" + +if test $# -lt 2; then + echo "${usage}" 1>&2 + exit 1 +fi + +eval last=\${$#} +while test $# -gt 1; do + tmsu tag --from $1 $last && tmsu-fs-rm $1 + shift +done diff --git a/misc/bin/tmsu-fs-mv b/misc/bin/tmsu-fs-mv new file mode 100755 index 00000000..eb103e59 --- /dev/null +++ b/misc/bin/tmsu-fs-mv @@ -0,0 +1,13 @@ +#!/bin/sh + +usage="\ +Moves a file in the filesystem and updates the path in TMSU + +Usage: $0 SRCFILE DESTFILE" + +if test $# -ne 2; then + echo "${usage}" 1>&2 + exit 1 +fi + +mv $1 $2 && tmsu repair --manual $1 $2 diff --git a/misc/bin/tmsu-fs-rm b/misc/bin/tmsu-fs-rm new file mode 100755 index 00000000..12cdad85 --- /dev/null +++ b/misc/bin/tmsu-fs-rm @@ -0,0 +1,16 @@ +#!/bin/sh + +usage="\ +Delete a file in the filesystem and TMSU + +Usage: $0 FILE..." + +if test $# -lt 1; then + echo "${usage}" 1>&2 + exit 1 +fi + +while test $# -gt 0; do + tmsu untag --all $1 && rm $1 + shift +done diff --git a/misc/zsh/_tmsu b/misc/zsh/_tmsu index 88a9c074..ef79eb33 100644 --- a/misc/zsh/_tmsu +++ b/misc/zsh/_tmsu @@ -157,7 +157,7 @@ _tmsu_files() { _call_program tmsu tmsu $db files | while read -A file do - file_list+=$file:s/\.\/// + file_list+=$file done _describe -t files 'files' file_list diff --git a/src/tmsu/cli/tag.go b/src/tmsu/cli/tag.go index 0a5190c9..1f06b87f 100644 --- a/src/tmsu/cli/tag.go +++ b/src/tmsu/cli/tag.go @@ -253,7 +253,7 @@ func tagFrom(store *storage.Storage, tx *storage.Tx, fromPath string, paths []st return fmt.Errorf("%v: could not retrieve file: %v", fromPath, err) } if file == nil { - return fmt.Errorf("%v: path is not tagged") + return fmt.Errorf("%v: path is not tagged", fromPath) } fileTags, err := store.FileTagsByFileId(tx, file.Id, true)