Video generation with png frame with random name - Linux -


i have folder contains .png pictures named in following way:

name_number.png 

however number written in scientific way ( 1, 1e1, 1e2 ).

i create video, command line, combination of of them.

is there command linux takes consideration scientific name? should rename them command , generate video?

with ruby can tackle way:

def rename_sci(name)   name.sub(/(\d+e\d+)/) |m|     '%.0f' % $1.to_f   end end  %w[   test_1e1.png   test_1e2.png ].each |name|   puts '%s -> %s' % [     name,     rename_sci(name)   ] end 

where output like:

test_1e1.png -> test_10.png test_1e2.png -> test_100.png 

now can make actual renaming tool pretty easily:

require 'optparse'  def rename_sci(name)   name.sub(/([0-9]+e[0-9]+)/) |m|     '%.0f' % $1.to_f   end end  options = {   dry_run: false }  # use optionparser add --dry-run option testing program = optionparser.new |op|   op.on('-y', '--dry-run', 'dry run, no renaming occurs')     options[:dry_run] = true   end end  program.parse!(argv).each |path|   new_path = rename_sci(path)    next if (path == new_path)    puts '%s -> %s' % [ path, new_path ]    next if (options[:dry_run])    file.rename(path, new_path) end 

then can run script like:

rename_sci -y *.png 

if looks good, pull -y flag , let rip! always, make backups in case goes horribly awry.


Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -