Git Product home page Git Product logo

collect-zips-py's Introduction

Command line tool to collect and rename zip files

A command line tool to rename zip files to their parent directory name and copy (or move) them to other directory.

Usage

Suppose zip files are placed like this.

./sample/
└── dirs
    ├── dir1
    │   └── hoge.zip
    └── dir2
        └── fuga.zip

In order to copy these zips to sample directory with renaming them, run the following

python /path/to/colzips.py ./sample/dirs/ -d ./sample/

to get

./sample/
├── dir1.zip
├── dir2.zip
└── dirs
    ├── dir1
    │   └── hoge.zip
    └── dir2
        └── fuga.zip

The same result can be derived by running

python /path/to/colzips.py ./sample/ -d ./sample/

since it searches files recursively.

If you would like to move zip files instead of copying them, simply add -m option.

python /path/to/colzips.py ./sample/ -d ./sample/ -m

For more (nothing much) information, run

python /path/to/colzips.py --help

Install

The script depends only on standard libraries and click library. The following step can be skipped if you have these libraries with appropriate versions in your environment (see pyproject.toml).

  • Tested Environment
    • Windows 10 + WSL2 + Ubuntu 20.04
    • python 3.10.5 (pyenv 2.3.2) + poetry (1.1.11)

Follow a typical routine of setting up a virtual environment by pyenv + poetry.

Copy this project in some way, for instance, by git clone or create a repository from this template project.

git clone https://github.com/Shena4746/collect-zips-py.git
cd ./collect-zips-py

Enable python 3.10.5 at the top of the project directory. We do it simply by pyenv here.

pyenv local 3.10.5

It fails if you have not downloaded python 3.10.5. Run the following to download it, and try the previous command again.

pyenv install 3.10.5

Locate the python interpreter at {project-top}/.venv. Then let poetry perform a local installation of dependency.

python3 -m venv .venv
poetry install --no-dev

Make sure that poetry uses the intended python interpreter.

poetry run which python
poetry run python --version

collect-zips-py's People

Contributors

shenapse avatar

Watchers

 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.