I'm creating a timelapse video by splitting a video into individual images, using G'MIC via the command line to average every 7 frames, then output the results to new images which will result in the frames for the timelapse (this way I get noise free video that looks great). As you can imagine I have a lot of frames – several thousand individual images in a directory, named sequentially (image1.tiff, image2.tiff, etc.). I found a script that works perfectly for moving the files – once…
k=1; find source/ -type f | while read file; do
[[ k++ -le 7 ]] && mv "$file" target/
done
What I need now is to make this script
- repeat itself until all the files are moved and
- create sequentially numbered target directories (1, 2, 3, etc.) as it goes so I end up with several hundred directories each with 7 images inside.
Just to clarify, directory 1 should contain images 1-7, directory 2 should contain images 8-14, etc.
Any help is greatly appreciated, I'm pretty much stuck with this one.
Best Answer
The (python) script below creates sub folders and organizes your files into the folders:
Additionally:
The script assumes:
image1.tiff
,image2.tiff
etc (no leading zeros).The script
How to use
Copy the script into an empty file, in the head section, set the directory to your files and the number of files per sub directory, save it as
organize.py
.Run it by the command:
Note
If you'd like to move the files instead of copying, replace the line:
by:
(mind the indent!)