New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

tagtoname

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tagtoname - npm Package Compare versions

Comparing version 5.2.3 to 6.0.0

cli.js

51

index.js

@@ -1,13 +0,9 @@

"use strict";
import { constants } from "node:fs";
import { access, mkdir, rename } from "node:fs/promises";
import { basename, dirname, extname, join } from "node:path";
import { promisify } from "node:util";
import { lock as lockCb, unlock as unlockCb } from "lockfile";
import { parseFile } from "music-metadata";
import slugify from "standard-slugify";
const {
constants,
promises: { access, mkdir, rename },
} = require("fs");
const { basename, dirname, extname, join } = require("path");
const { promisify } = require("util");
const { lock: lockCb, unlock: unlockCb } = require("lockfile");
const { parseFile } = require("music-metadata");
const slugify = require("standard-slugify");
const lock = promisify(lockCb);

@@ -25,19 +21,3 @@ const unlock = promisify(unlockCb);

/**
* Renames an audio file using its metadata tags. Resolves with the new path.
*
* The first argument is the `path` of the file to be renamed.
*
* The second argument is an options object with the following properties:
*
* - `keepCase`: Keep the original case of the tags when renaming,
* defaults to `false`
* - `noop`: Perform a dry run without renaming the file,
* defaults to `false`
* - `separator`: The separator used to split the tags in the new name,
* defaults to `"-"`
* - `tags`: An array of the tags used in the new name,
* defaults to `["artist", "title"]`
*/
module.exports = async function (
export default async function (
path = "",

@@ -49,5 +29,14 @@ {

tags = ["artist", "title"],
} = {}
} = {},
) {
const { common } = await parseFile(path);
let common;
try {
({ common } = await parseFile(path));
} catch (error) {
if (error.message.includes("ENOENT")) {
throw Error(`Failed because '${path}' does not exist`);
} else {
throw Error(`Failed to parse file '${path}'`);
}
}
const name = tags

@@ -97,2 +86,2 @@ .reduce((tags, key) => {

return newPath;
};
}
{
"name": "tagtoname",
"version": "5.2.3",
"version": "6.0.0",
"description": "Renames audio files using the metadata tags",

@@ -22,31 +22,37 @@ "keywords": [

"files": [
"bin/cli.js",
"index.js"
"cli.js",
"index.js",
"index.d.ts"
],
"main": "index.js",
"bin": "bin/cli.js",
"bin": {
"tagtoname": "cli.js"
},
"repository": {
"type": "git",
"url": "https://github.com/rtomrud/tagtoname.git"
"url": "git+https://github.com/rtomrud/tagtoname.git"
},
"scripts": {
"format": "prettier --check .",
"lint": "eslint .",
"start": "node bin/cli.js",
"test": "jest",
"posttest": "npm run lint"
"start": "node ./cli.js",
"test": "node --test --experimental-test-coverage",
"posttest": "npm run lint && npm run format"
},
"dependencies": {
"getopts": "2.3.0",
"glob": "10.3.12",
"lockfile": "1.0.4",
"music-metadata": "7.12.5",
"standard-slugify": "3.1.1"
"music-metadata": "7.14.0",
"standard-slugify": "4.0.0"
},
"devDependencies": {
"eslint": "8.20.0",
"eslint-config-pretty-strict": "8.1.1",
"eslint-plugin-jest": "26.6.0",
"eslint-plugin-prettier": "4.2.1",
"jest": "28.1.3",
"prettier": "2.7.1"
"@eslint/js": "9.1.1",
"eslint": "8.57.0",
"prettier": "3.2.5"
},
"type": "module",
"exports": {
"types": "./index.d.ts",
"default": "./index.js"
}
}
# tagtoname
[![build status](https://github.com/rtomrud/tagtoname/workflows/ci/badge.svg)](https://github.com/rtomrud/tagtoname/actions?query=branch%3Amaster+workflow%3Aci)
[![npm version](https://badgen.net/npm/v/tagtoname)](https://www.npmjs.com/package/tagtoname)
Renames audio files using the metadata tags

@@ -17,3 +14,3 @@

```
Usage: tagtoname [-k] [-n] [-s separator] [-t tag]... file...
Usage: tagtoname [-i] [-k] [-n] [-s separator] [-t tag]... file...

@@ -24,2 +21,3 @@ Renames audio files using the metadata tags.

-i, --ignore Ignore a glob pattern
-k, --keep-case Keep the original case of the tags when renaming

@@ -48,4 +46,7 @@ -n, --noop Dry run, show new paths without renaming the files

# Rename all files in a folder.
tagtoname folder/*
# Rename all files in a directory.
tagtoname directory/*
# Rename all files in the current directory and its subdirectories
tagtoname **/*
```

@@ -59,4 +60,4 @@

# Dry run, output what would happen if we were to rename all files in a folder.
tagtoname -n folder/*
# Dry run, output what would happen if we were to rename all files in a directory.
tagtoname -n directory/*

@@ -66,3 +67,3 @@ # Rename a file using a custom separator.

# "Reverie", the file will be renamed to "debussy/reverie.mp3" (since the
# separator is "/", the folder "debussy" is created if needed).
# separator is "/", the directory "debussy" is created if needed).
tagtoname -s / file.mp3

@@ -108,3 +109,3 @@

// assuming the artist tag is "Queen" and the title tag is "Bohemian Rhapsody"
// (since the separator is "/", the folder "queen" is created if needed).
// (since the separator is "/", the directory "queen" is created if needed).
tagtoname("/file.mp3", { separator: "/" }).then(console.log);

@@ -111,0 +112,0 @@ // => /queen/bohemian-rhapsody.mp3

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc