Skip to content

Another simple shell script which adds the given tags to the file names of all files in the given directory

License

Notifications You must be signed in to change notification settings

kyusu/tagsToFileNames

Repository files navigation

tagsToFileNames

Node.js CI Maintainability Coverage Status Known Vulnerabilities dependencies Status devDependencies Status Maintenance GitHub license DeepScan grade

A simple shell script which adds/removes the given tags to/from the file names of all files which are piped into the script.

The concept of tags contained in the file names itself is heavily inspired by TagSpaces.

Install

NPM

$ npm install -g tagsToFileNames

Usage

Add tags

Let say you have a directory containing these files like so

total 0
drwxr-xr-x  12 kyusu  staff  408 30 Okt 15:13 .
drwxr-xr-x   5 kyusu  staff  170 30 Okt 15:11 ..
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 1153296479.jpg
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 1213079645.jpg
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 1335702062.jpg
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 1615566250.jpg
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 1881347061.jpg
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 1994615544.jpg
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 212491440.jpg
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 552716224.jpg
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 592280349.jpg

and would like to store tags à la TagSpaces in the file names, you can do so by piping these files in to tagsToFileNames:

    $ ls | tagsToFileNames add foo,bar,baz

which will result in

total 0
drwxr-xr-x  12 kyusu  staff  408 30 Okt 15:13 .
drwxr-xr-x   5 kyusu  staff  170 30 Okt 15:11 ..
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 1153296479.[foo bar baz].jpg
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 1213079645.[foo bar baz].jpg
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 1335702062.[foo bar baz].jpg
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 1615566250.[foo bar baz].jpg
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 1881347061.[foo bar baz].jpg
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 1994615544.[foo bar baz].jpg
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 212491440.[foo bar baz].jpg
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 552716224.[foo bar baz].jpg
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 592280349.[foo bar baz].jpg

Remove tags

If you later on decide to remove baz you can do so by running

    $ ls | tagsToFileNames remove baz

which will result in

total 0
drwxr-xr-x  12 kyusu  staff  408 30 Okt 15:13 .
drwxr-xr-x   5 kyusu  staff  170 30 Okt 15:11 ..
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 1153296479.[foo bar].jpg
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 1213079645.[foo bar].jpg
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 1335702062.[foo bar].jpg
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 1615566250.[foo bar].jpg
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 1881347061.[foo bar].jpg
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 1994615544.[foo bar].jpg
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 212491440.[foo bar].jpg
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 552716224.[foo bar].jpg
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 592280349.[foo bar].jpg

Filtering using tags

If you're directory looks like this

total 0
drwxr-xr-x  12 kyusu  staff  408 30 Okt 15:13 .
drwxr-xr-x   5 kyusu  staff  170 30 Okt 15:11 ..
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 1153296479.[foo bar].jpg
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 1213079645.[foo].jpg
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 1335702062.[foo bar].jpg
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 1615566250.[foo].jpg
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 1881347061.[foo].jpg
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 1994615544.[foo bar].jpg
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 212491440.[foo].jpg
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 552716224.[foo].jpg
-rw-r--r--   1 kyusu  staff    0 30 Okt 15:12 592280349.[foo].jpg

and you want to work with all files which are tagged with bar you can run

    $ ls | tagsToFileNames filter bar

which will print only these files which are tagged with bar.

Adding tags to subdirectories

If you want to add tags to files in subdirectories you can do so using find

   $ find . | tagsToFileNames add foo

License

MIT

About

Another simple shell script which adds the given tags to the file names of all files in the given directory

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •