Extension of the unix mv command, which will also searches through your files and updates any references to the file that you just moved.
Project description
pyfilemv
This small python package provides an extension to the normal unix mv
command.
In addition to simply renaming a file or directory, pymv also searches through user-defined directories and asks the user if he or she wants to update any reference to the file that was renamed. Thus, you do not have to manually update all scripts or documents that reference that file. For a showcase of the package, see the Demonstration below.
Installation
pymv can simply be installed via PyPI .
pip install pyfilemv
Usage
Use pymv
just like you would use mv
, i.e. specify the file or directory which you want to rename as well as the new
name as positional arguments. In addition you have to set a root directory using the -r
flag.
pymv
will then search through files and subdirectories that are part of the root directory. Only files that have a
specific file extension (by default: R, Rmd, RMD, txt, py, ipynb, md, pl, cpp or java) will be evaulated.
You can extend the list of extensions, either by adding file extensions with the -e
flag, or by creating a file .pyfilemv
file in
your home directory, where each line corresponds to one file extension.
You can also set the -a
flag, if you only want to search and replace absolute paths. This might be helpful if you get to many
'false positive' hits.
If pymv
finds a match in any of the files, it shows you the old line and how the new line would look like if you want to
update the file. You can confirm that you want to do the replacement by typing y
.
You can get help by running pymv -h
usage: pymv [-h] [-r ROOT] [-e EXTENSION [EXTENSION ...]] [-a] source destination
positional arguments:
source Source file.
destination Destination of the source file after the move.
optional arguments:
-h, --help show this help message and exit
-r ROOT, --root ROOT Specify the absolute path to a directory. All files that are part of that directory (and also subdirectories) are checked if
they contain the file you want to move.
-e EXTENSION [EXTENSION ...], --extension EXTENSION [EXTENSION ...]
Specify file extensions which should be included in the search. Should look like this: -e ext1 ext2 ext3. By default, the
program searches in the following files: R, Rmd, RMD, txt, py, ipynb, md, pl, cpp, and java
-a, --absolute If you set this flag, the program will search for the absolute filepath.
Demo
Below is a small demo to showcase the function of the package. Here, we use it to rename a results object and show that the documentation that we wrote for this object, was automatically updated.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pyfilemv-1.0.2.tar.gz
.
File metadata
- Download URL: pyfilemv-1.0.2.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3943e94896600cfd37ee833dcaccc9d81b22f2083df0b7defb006d48d80eaf00 |
|
MD5 | 4b58092a24611c5575894a7fd51b08c0 |
|
BLAKE2b-256 | 63855caa92bc79de29a2efa09e59e1d0f7b3ece647c8f75f6af5aef745a01b1f |
File details
Details for the file pyfilemv-1.0.2-py3-none-any.whl
.
File metadata
- Download URL: pyfilemv-1.0.2-py3-none-any.whl
- Upload date:
- Size: 13.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e0208015f9b7516b854d74bdc5b67a0de918460b55c8f1d4bea9e411ee96ea5 |
|
MD5 | 570e0e0a58dcc140550c1018f50e5654 |
|
BLAKE2b-256 | c2a964fced035d5f22e6c98ffca33f04f1160206dfaabb56b0dce7f2dccfa6e0 |