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.

Source Distribution

rpt-2.1.0.tar.gz (5.0 kB view details)

Uploaded Source

File details

Details for the file rpt-2.1.0.tar.gz.

File metadata

  • Download URL: rpt-2.1.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.5

File hashes

Hashes for rpt-2.1.0.tar.gz
Algorithm Hash digest
SHA256 0035aba6e1ad54f987f8afe77ee7438d7717b859fbf40d074ffa347b92e04b3e
MD5 6997b020c54f07dc437e6e52c112ad14
BLAKE2b-256 0e821d535e4f7d9bc6d71db72705a5e03fa15372d7463a0b09b02ac15355dac8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page