Git Product home page Git Product logo

copy_filenames_from_txt's Introduction

Copy Filenames from .txt Document

made-with-bash

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.

Setup/Installation/How to use

  • git clone this repo to somewhere you want to store the bash script
  • chmod u+x ./copy_filenames_from_txt.sh make the script executable
  • Use away!

But Why Though?

  • 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.

Demo Example

asciicast

Screenshots

File Setup

file_setup

Copying Files

copying

Files Already Exist

already_exists

Usage Example

Help Output [CLI]

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.

Notes

  • 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.
  • 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.

TODO

  • Testing
  • Loading bar or indicator
  • Improve name
  • Handle other delimiter

copy_filenames_from_txt's People

Contributors

jordyjwilliams avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.