Advertisement
sxiii

Bash fix filenames order (common linux file misordering)

Apr 29th, 2017
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.53 KB | None | 0 0
  1. #!/bin/bash
  2. # This scripts helps you to fix file ordering linux issues.
  3. # They are related to the idea that images without leading zeros (frame1.png but not frame0001.png)
  4. # is incorrectly ordered by the system and, thus, cannot be used in ffmpeg or wherever other scripts,
  5. # in a correct order. So, this scripts adds leading zeros. In this example, in scans file from 1 to 2500.
  6.  
  7. m1=($(seq 1 2500))
  8. m2=($(seq -w 0001 2500))
  9.  
  10. echo ${m1[20]}
  11. echo ${m2[20]}
  12.  
  13. for i in {1..2500..1}; do
  14. mv frame${m1[$i]}.png frame${m2[$i]}.png
  15. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement