kaki-utils 0.1.10 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/kaki/utils.rb +18 -0
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0749cd8e17d8067cd321cdb44972ead355f2e5c267bfc98299e00ee357668d6a'
4
- data.tar.gz: a132888a9c3fc57677c6c4175cce0a5d0ad8972d9dcc7ddd4b10c9683447c216
3
+ metadata.gz: 81f03f7dddfeb7e6a8a1bcb0a57ae9aff06223a1e4eb296500a75dfa8918c467
4
+ data.tar.gz: cb7bccdddb87cf1864c1b0ecad7d47e869759f5f945f0fa1336d7fa11866be74
5
5
  SHA512:
6
- metadata.gz: 33e6e2c77c6dfd161d9436a43355ce497010429d796643b387e1e0768ba0289af7ae74f94fb792e1a30c8b233b1d9a2e56ca94272c88a04aa0c42243740440f4
7
- data.tar.gz: 18267187cd15833a87e0fea4563500bb5ac7bfe488816e030ebd8e54dc7e75fd65f3a40daa0409b0c9337076e6af2a47ac164f93ca97db073f8c4bcfadc868ee
6
+ metadata.gz: 97ec306405102bbd7d6362ea78a2a76a1870c583041754d0bda295d0f0a5819b1a625d92f8e679f71274c907d32bb8394718071e1c4e4983a21a58a9b048af6a
7
+ data.tar.gz: 2ed2cedd1d6711f44050f1bf6dc74c9f8f5ccef5f46ee0abcc14c2316139c29cc78494b13282f3d32e776ffcfe323c4790024a0cc41a68683db2cf2750be0863
data/lib/kaki/utils.rb CHANGED
@@ -162,4 +162,22 @@ module Utils
162
162
  %x(ffmpeg -i #{url} -movflags faststart -c copy -bsf:a aac_adtstoasc #{fname})
163
163
  end
164
164
  module_function :m3u8
165
+
166
+
167
+ #連番ファイル名を sort 順になるように変更する
168
+ def modify_serial_numbers(dir = Dir.pwd)
169
+ Dir.chdir(dir)
170
+ files = Dir.glob("*").select {|fn| File.file?(fn)}
171
+ data = files.map do |fn|
172
+ m = /^(.*?\D*?)(\d+)(\..+)$/.match(fn)
173
+ next unless m
174
+ [fn, m[1], m[2].to_i, m[3]]
175
+ end.compact
176
+ num_length = data.map {|d| d[2].to_s.length}.max
177
+ data1 = data.map {|d| [d[0], d[1] + ("%0#{num_length}d" % d[2]) + d[3]]}
178
+
179
+ Dir.mkdir("new_folder")
180
+ data1.each {|be, af| FileUtils.cp(be, "new_folder/#{af}")}
181
+ end
182
+ module_function :modify_serial_numbers
165
183
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kaki-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - obelisk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-15 00:00:00.000000000 Z
11
+ date: 2019-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fastimage