Browse Source

renamepdfs: PDF rename script

master
Maxim Likhachev 6 years ago committed by Maxim Likhachev
parent
commit
6c078fab23
  1. 1
      README.md
  2. 39
      renamepdfs

1
README.md

@ -27,6 +27,7 @@ will create the symbolic link for each script in the \<path> directory.
- [fontsel](fontsel) shows the available console fonts. - [fontsel](fontsel) shows the available console fonts.
- [fsz](fsz) adjusts console font size. - [fsz](fsz) adjusts console font size.
- [hr](hr) displays horizontal rule with current time. - [hr](hr) displays horizontal rule with current time.
- [renamepdfs](renamepdfs) renames PDF files using their metadata.
- [vcat](vcat) displays file content with [syntax highlighting](https://www.gnu.org/software/src-highlite/) (see also [bat](https://github.com/sharkdp/bat)). - [vcat](vcat) displays file content with [syntax highlighting](https://www.gnu.org/software/src-highlite/) (see also [bat](https://github.com/sharkdp/bat)).
- [viper](viper) is a simple alternative to viper from [moreutils](https://joeyh.name/code/moreutils/) package which can be used with custom vim parameters. - [viper](viper) is a simple alternative to viper from [moreutils](https://joeyh.name/code/moreutils/) package which can be used with custom vim parameters.

39
renamepdfs

@ -0,0 +1,39 @@
#!/bin/bash
# Интерактивное переименование PDF-файлов, используя информацию из метаданных
filelist() {
for f in "$@"; do
echo "\"$f\""
done
}
DIR=$(pwd)
FILES=()
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-d|--directory)
DIR="$2"
shift # past argument
shift # past value
;;
*)
FILES+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
set -- "${FILES[@]}"
if [ "${#FILES[@]}" -gt 0 ]; then
filelist "${FILES[@]}" | viper +'set ft=rename' +"let b:rename_dir=\"$DIR\"" | sed "s/^/mv /" | sh
else
echo "USAGE: $(basename $0) [-d/--directory <dir>] file1.pdf file2.pdf [...]"
exit 1
fi
Loading…
Cancel
Save