Skip to content

useless-utils/copycheck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

copycheck: a command-line tool for returning filenames with copy identifiers

copycheck is a Linux command-line tool that allows the renaming a file to include a copy identifier if a file with the same name already exists in a specified directory. This can be useful to keep multiple copies of a file in the same directory, but need to ensure that each copy has a unique name.

Notes

  • This tool doesn’t make filesystem changes, it only prints to the terminal.
  • copycheck only works with files, not directories.
  • If the --dir option is not specified, copycheck will use the current directory as the target directory.
  • If the --padding option is not specified, copycheck will use a default value of 2 padding zeros for the copy identifier, e.g: ”01”.
  • If a file with the same name as the renamed file already exists, copycheck will increment the copy identifier and try again until a unique name is found.

Installation

To install copycheck, clone this repository and build the executable using the Haskell’s cabal build system:
git clone https://codeberg.org/11xx/copycheck
cd copycheck
cabal install

This will build the executable and link it to Cabal’s default install directory, that can be set by the CABAL_DIR environment variable; or the location specified by installdir: in Cabal’s config file. This directory can then be added to PATH to make the copycheck command available globally.

Usage

To use copycheck, open a terminal and point it to the directory containing the file to be renamed. Then, run the copycheck command with the following options:
copycheck --file <filename> --text <copy-text> --dir <directory> --padding <num-padding-zeros>
  • --file: the path to the file to be renamed (required)
  • --text: the string to be added to the file name to indicate it is a copy (optional, defaults to _COPY_)
  • --dir: the directory where the file is located (optional, defaults to the current directory)
  • --padding: the number of padding zeros to be added to the copy identifier (optional, default is 2, producing a number such as “02”)

Example

Here is an example of how copycheck might be used to rename a file:
copycheck --file "report.txt" --text "_copy" --dir "documents" --padding 3

This will rename the file report.txt to documents/report_copy001.txt if a file with that name already exists in the documents directory. If a file with that name does not exist, the original file will not be renamed.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published