Capture of every 4th file

I have 16,000 JPG from the invader scanner, which I released over the course of the year, pointing to the rear year. I want to find a way to capture every fourth image, then put them in another directory, then later turn them into a movie. Is there a simple bash script or another way under Linux that I can do this.

They are named so ...

frame-44558.jpg

frame-44559.jpg

frame-44560.jpg

frame-44561.jpg

Thank you for the help of newb.


It seems to have worked. A couple of errors in my original mail. In fact, there were 280,000 images, and was named. / home / baldy / Desktop / webcamimages / webcam _2007-05-29_163405.jpg / home / baldy / Desktop / webcamimages / webcam _2007-05-29_163505.jpg / home / baldy / Desktop / webcamimages / webcam _2007-05-29_163605. jpg

. cp $(ls | awk '{nr ++; if (nr% 10 == 0) print $0}')../newdirectory/

. 70-900 .

 mencoder mf://*.jpg -mf w = 640: h = 480: fps = 30: type = jpg -ovc lavc -lavcopts vcodec = msmpeg4v2 -nosound -o../output-msmpeg4v2.avi

, .

UPDATE: . 2007 , 2008 . webcam_2008-02-17_101403.jpg webcam_2008-03-27_192205.jpg webcam_2008-02-17_102403.jpg webcam_2008-03-27_193205.jpg webcam_2008-02-17_103403.jpg webcam_2008-03-27_194205.jpg webcam_2008-02-17_104403.jpg webcam_2008-03-27_195205.jpg

mencoder , ?

+3
8

:

$ touch a b c d e f g h i j k l m n o p q r s t u v w x y z
$ mv $(ls | awk '{nr++; if (nr % 4 == 0) print $0}') destdir

+11

script move.sh, :

#!/bin/sh
mv $4 ../newdirectory/

, :

ls *.jpg | xargs -n 4 ./move.sh

, move.sh, .

, (, , mod 4 ).

+2

,

seq -f 'frame-%g.jpg' 1 4 number-of-frames

, "ls" ​​ 280k. , :

for f in `seq -f 'frame-%g.jpg' 1 4 number-of-frames` ; do
  mv $f destdir/
done
+2

perl (, bash) - , , 4

- :

ls -1 /path/to/files/ | perl -e 'while (<STDIN>) {($seq)=/(\d*)\.jpg$/; print $_ if $seq && $seq % 4 ==0}'

...

, , , file_9.jpg, file_10.jpg)

+1
seq -f 'frame-%g.jpg' 1 4 number-of-frames

... .

+1

masto :

ls | sed -n '1~4 p' | xargs -i mv {} ../destdir/

, , - , , , .

+1

:

files=( frame-*.jpg )
i=0
while [[ $i -lt ${#files} ]] ; do
  cur_file=${files[$i]}
  mungle_frame $cur_file
  i=$( expr $i + 4 )
done
0

, . , cd'd , :

mkdir ../outdir
ls | sort -n | while read fname; do mv "$fname" ../outdir/; read; read; read; done

sort -n , ; ls , frame-123.jpg frame-4.jpg, , .

, , , .. , .

, , . , , , , .

0

Source: https://habr.com/ru/post/1696952/


All Articles