Package: reFILE
List, rename and delete files using Python-style regex.THIS PROGRAM IS STILL IN THE ALPHA TESTING STAGE SO PLEASE ENSURE THAT YOU
KEEP REGULAR BACKUPS AND DO NOT USE IT ON ANY IMPORTANT DOCUMENTS OR FILESInstallationreFILE should be available on the PyPI repository so installing should be as
simple as:$ pip install reFILEAlternatively you can clone the github repository and use setuptools, like so:$ git clone https://github.com/Sean1708/reFILE.git
$ python setup.py installreFILE uses the pathlib module which only has tentative support for Python 2.
For this reason, it is reccomended that you use Python 3 to download reFILE.
Having said this, however, reFILE should still work on Python 2 installations.IssuesIf you find any bugs or just generally have somee issues, feel free to open an
issue ticket at mygithub repo.Alternatively, if you fancy fixing it yourself just send me a pull request or
diff file via github and I’ll be happy to incorporate your code.LibraryI have plans to make this package usable as a library but at the moment am
unsure how best to approach it. If you have any thoughts feel free to contact
me.DocumentationThe refile command line utility performs three useful tasks on a directory of
files; listing files which match a regular expression, renaming files which
matche a regular expression and deleting files which match a regular
expression.Usage:$ refile -h
$ refile ls [-h] [-rqvn] [-L LIM] [-I PAT] PATTERN [DIR]
$ refile mv [-h] [-rqvdif] [-L LIM] [-I PAT] [-m DIR] PATTERN REPLACE [DIR]
$ refile rm [-h] [-rqvdif] [-L LIM] [-I PAT] PATTERN [DIR]General UsageTo avoid issues with variable expansion and special characters on the command
line it is advisable to enclose the regular expression in single quotes:$ refile ls '.*'without the quotes this would cause a list of all files whose name starts with
a period to be passed torefilewhich would, unsurprisingly, lead to
unexpected behaviour.If no directory is specified, the current directory is searched. A directory
can be specified as an absolute path or a relative one, if an absolute path is
used then filenames will be printed as an absolute path and similarly for
relative paths. Tilde expansion is performed at the command line but not within
the program so wrapping your directory in single quotes is ill-advised.OptionsAll options in reFILE must be specified after the subcommand. Many of the
options are shared between subcommands, they are:-h,--helpprint a useful help message-r,--recursesearch directories recursively-q,--quietsupress all output except errors-v,--verboseprint extra information-LLIM,--limit=LIMmaximum depth limit when searching recursively-IPAT,--ignore=PATignore any files which match the regex PATListing FilesUsage:$ refile ls [-h] [-rqvl] [-L LIM] [-I PAT] PATTERN [DIR]Thelssubcommand lists all files in the directoryDIRwhich match the
regular expressionPATTERN. Internally this is run using there.searchfunction so the pattern can match any part of the filename, not just the start.Options-h,--helpprint a useful help message-n,--no-columnsuppress columnated output-l,--longprint extra information about the filesRenaming FilesUsage:$ refile mv [-h] [-rqvdif] [-L LIM] [-I PAT] [-m DIR] [-D FORMAT]
            PATTERN REPLACE [DIR]Themvsubcommand renames any file in the directoryDIRwhich matches
the regular expressionPATTERNto the nameRENAME. This is run
internally using there.subfunction.IfPATTERNmatches more than once in the filename then each match will be
replaced by the stringREPLACEproviding the matches don’t overlap. If the
regular expression matches the entire filename thenPATTERNandREPLACEmust contain groups and backreferences to avoid files overwriting eachother.
This is not checked at run-time so it is up to the user to ensure proper usage.If the-Doption is specified the creation time of the file will be
prepended to theREPLACEstring before the rename takes place. TheFORMATstring is passed to thetime.strftimefunction so refer to that
for more information.Options-h,--helpprint a useful help message-d,--directoriesrename directories-i,--confirmprompt for confirmation before renaming files-f,--forcenever prompt for confirmation-mDIR,--moveto=DIRmove files into directory DIR-DFORMAT,--date=FORMATprepend creation time according to strftime formatDeleting FilesUsage:$ refile rm [-h] [-rqvdif] [-L LIM] [-I PAT] PATTERN [DIR]Thermsubcommand deletes all files in the directoryDIRwhich match
regular expressionPATTERN. The search is performed identically to thelssubcommand so a good way to ensure that you are deleting the correct
files is to run the command aslsfirst.Options-h,--helpprint a useful help message-d,--directoriesdelete directories if empty-i,--confirmprompt for confirmation before deleting files-f,--forcenever prompt for confirmation