21 lines
316 B
Ruby
Executable File
21 lines
316 B
Ruby
Executable File
#!/usr/bin/env ruby
|
|
|
|
filename = ARGV.last
|
|
|
|
unless filename
|
|
warn "Please supply a filename"
|
|
exit 1
|
|
end
|
|
|
|
content = File.read(filename)
|
|
|
|
links = content.scan(/\[\d+\]/).uniq
|
|
|
|
links.zip(1..).each do |old_id, new_id|
|
|
content.gsub! old_id, "[$$#{new_id}]"
|
|
end
|
|
|
|
content.gsub!("$$", "")
|
|
|
|
File.write(filename, content)
|