Created
August 8, 2020 23:55
-
-
Save hyuki/2bdb787002438bd451cd71552b8f9b63 to your computer and use it in GitHub Desktop.
paper-fig.rb - 指定ディレクトリ中の "Paper.*.png" を "paper-*.png"に置き換えてLaTeXのソースを表示するRubyスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
APPNAME = 'paper-fig' | |
if ARGV.size != 1 | |
puts "#{APPNAME} DIRNAME" | |
puts "DIRNAMEのディレクトリからPaper.*.pngのファイルを探してリネームしてLaTeXソースを表示する" | |
abort | |
end | |
dirname = ARGV[0] | |
counter = 1 | |
Dir.chdir(dirname) do | |
Dir.glob("Paper.*.png").sort {|a, b| File.mtime(a) <=> File.mtime(b) } .each do |filename| | |
newfilename = nil | |
loop do | |
newfilename = "paper-#{counter}.png" | |
if not File.exists?(newfilename) | |
break | |
end | |
counter += 1 | |
end | |
system("mv #{filename} #{newfilename}") | |
s = "\\FIGURECAPTIONWIDTH{#{dirname}/#{newfilename}}{#{newfilename}}{\\FULLWIDTH})" | |
puts | |
puts s | |
puts | |
cmd = "echo '#{s}' | pbcopy" | |
system(cmd) | |
puts "クリップボードにコピーしました" | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment