Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redo-subst #4

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions Documentation/redo-subst.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
% redo-subst(1) Redo 0.00
% Andreas Krennmair <ak@synflood.at>
% 2011-01-16

# NAME

redo-subst - substitute file suffixes

# SYNOPSIS

redo-subst suffix replacement [sources...]


# DESCRIPTION

redo-subst takes a file suffix, a replacement suffix and
a list of file names on which the file suffix shall be substituted
with the replacement suffix. For every file name that ends
with the specified suffix, the suffix is removed, the
replacement suffix is appended and the resulting file name
is printed out. File names whose suffix does not match
are printed out unmodified.

# REDO

Part of the `redo`(1) suite.

# CREDITS

The original concept for `redo` was created by D. J.
Bernstein and documented on his web site
(http://cr.yp.to/redo.html). This independent implementation
was created by Avery Pennarun and you can find its source
code at http://github.com/apenwarr/redo.


# SEE ALSO

`redo`(1)
1 change: 1 addition & 0 deletions redo-subst
13 changes: 13 additions & 0 deletions redo-subst.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/python
import sys, os

if len(sys.argv) < 4:
sys.exit(0)

fromsuffix = sys.argv[1]
tosuffix = sys.argv[2]

for file in sys.argv[3:]:
if file[-len(fromsuffix):] == fromsuffix:
file = file[0:-len(fromsuffix)] + tosuffix
print file