Tested with Deno v0.15.0
Prefixes all files with given FILE_EXTENSION in DIRECTORY with the FILE_PREFIX. If the prefix already exists on the file the prefix is skipped.
To install:
- Install deno
- Install deno_installer from deno_std
Then to install prefix_file run:
deno_installer prefix_file https://gist.githubusercontent.com/johnsonjo4531/3a18bc4539be33a2cfd965f93e12cdc6/raw/2c515c413940b93df599c5e2646136a13e4f9f4c/prefix_file.ts -A
Then to install unprefix_file run:
deno_installer unprefix_file https://gist.githubusercontent.com/johnsonjo4531/3a18bc4539be33a2cfd965f93e12cdc6/raw/2c515c413940b93df599c5e2646136a13e4f9f4c/unprefix_file.ts -A
Think of this as an interactive mode. This may be helpful if you want to see every file the script is reading and writing. The read access of a directory is so that the program can know the filenames in the directories (and therefore it may attempt to rewrite). The read and write access of the file means the program will attempt to rename that file.
prefix_file DIRECTORY FILE_PREFIX FILE_EXTENSION
or:
unprefix_file DIRECTORY FILE_PREFIX FILE_EXTENSION
This will be helpful if you want to ignore all permissions warnings. Notice the addition of the -A flag this tells Deno (the typescript runtime) to allow all possible permissions:
prefix_file -A DIRECTORY FILE_PREFIX FILE_EXTENSION
or:
unprefix_file -A DIRECTORY FILE_PREFIX FILE_EXTENSION
(All files in this Gist are MIT LICENSED)