Skip to main content

# Repetitive command line creation with your editor of choice

Project description

Given a list of file names, this will put the list of files into a text file, open that with $EDITOR (or $VISUAL if $EDITOR is not set). After the editor returns, any changed names in the text file will cause a command (default: mv) to be executed with the original and new filename.

This is very useful in carrying out rename operations that are easy to specify with your text editor, but hard to specify with wildcards.

If you ever wrote something like this (and -- as seen here -- still got shell quoting wrong, because it's tedious), then this tool is for you:

for f in *.mp3; do; mv "$f" "$(basename $f .mp3)_foo.mp3"; done

Also, you can use different commands instead of mv, and add options for the input and output parameters (oggenc <infile> -o <outfile>):

rpt -c "oggenc {old} -o {new}" *.wav

If you have a command without {old} and {new}, {old} {new} will be appended to the command line (cp <infile> <outfile>):

rpt -c cp *.wav

You can put {old} and {new} wherever you want, in different order and also multiple times (if needed):

rpt -c "mpg123 -w {new} {old}" *.mp3

To go all-out silly, you can set the $EDITOR variable to something that will automatically change each input line, for example to make a backup file of every .py file in the current folder:

env EDITOR="sed -i -e '/^[^#]/ s/$/.bak/'" rpt -c cp *.py

This will use sed as the editor and in-place edit the temporary text file created by rpt and append .bak to all non-comment lines (the /^[^#]/ part) in the input file, and with cp as the command will call cp <filename> <filename>.bak for every input file.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for rpt, version 2.0.0
Filename, size File type Python version Upload date Hashes
Filename, size rpt-2.0.0.tar.gz (4.7 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page