bash
CLI tool to recursively copy files whose name contains (partially) entries in a .txt
file.
An output directory, search directory and file containing the sub-strings to match each filename to can all be passed.
git clone
this repo to somewhere you want to store the bash scriptchmod u+x ./copy_filenames_from_txt.sh
make the script executable- Use away!
- You're working with a bunch of files (images in my example).
- You've made a selection and have a list of filenames (or partial/substrings from filenames)
- You don't want to go through like a chump clicking manually on each one.
- Solution: This
bash
tool.- Simple to run.
- Handles the case where more than one file matches the sub-string.
- Only the files that match lines in the supplied input file will be copied.
- Will not overwrite or remove data.
- Supports local and absolute paths.
Batch copy helper. Recursively search a directory for all filenames containing a sub-string based on an input file.
Uses an input file with each line containing a sub-string to search for.
Syntax: copy_filenames_from_txt.sh [-v|h] [-f file|-d dir|-o dir]
options:
-f File with desired sub-strings of filenames to copy. Usually .txt. Each search string on new line.
-d Search directory. Will be recursively searched for any matches in -f. Usually ./ (if cd is desired directory).
-o Output directory. To copy all matching files to. Note: will be created if does not exist.
-V Display Version string: 0.0.1.
-h Display this Help.
-v Verbose prints.
- Quick personal project to play around with
bash
- Feel free to comment or make changes
- I have only tested with a
.txt
file as the-f
input file parameter.- Should probably work with other file types that can be read by
UNIX
.
- Should probably work with other file types that can be read by
- I have assumed all input files will be use a new line as a delimiter.
- Could look into this in the future...
- I have only tested this locally on a Linux container.
- Testing
- Loading bar or indicator
- Improve name
- Handle other delimiter