I am working on a project that involves analyzing videos filmed on a GoPro in ImageJ; unfortunately, this means I have to convert all my videos (~400) to TIFF stacks. Therefore, I would like to create a batch file that will take a folder of MP4 videos, convert them to AVI files at 10fps with the first 4:20 removed, then convert those AVI files to TIFF stacks and have the resulting TIFFs sorted into folders based on their names. I have tried going straight from MP4 to TIFF and have always gotten an error message, hence the MP4 to AVI to TIFF conversions.
I have been going at this in a step wise manner by finding other batch codes people have developed on here, and I have gotten to the point where the batch file will convert the videos to TIFF files with sequential numbers at the end of the file names for the TIFF stacks, but I am struggling to get the sorting into folders part correct.
The file naming convention I have been using is just the standard GoPro naming convention but with the addition of sequential numbers (i.e., GOPR0210_0001.tiff, GOPR0210_0002.tiff, etc.) so that the TIFF stack is in the correct order.
Right now what I have is:
@echo off
for %%f in (*.MP4) do ffmpeg -y -ss 00:04:20 -i "%%f" -r 10 -qscale 0 "%%~nf_10fps.avi"
for %%f in (*.AVI) do ffmpeg -i "%%f" -pix_fmt rgba -compression_algo deflate %%~nf_%%05d.tiff
for %%a in (*.tiff) do (
set f=%%a
set g=!f:~0,10!
md "!g!" 2>nul
move "%%a" "!g!"
)
pause
I got the listed code for moving the files from .bat file sorting files into folders but I just end up with all my TIFF files sorted into a folder called "!g!"
I have also looked at/tried:
- Batch File to Move Files with Same Beginning String to a Folder with That String Name
- Batch create folders based on part of file name and move files into that folder
- Batch Create a Folder Based on Filename, and Move Multiple Related Files to The Created Folder
- Batch File to Move Files with Same Beginning String to a Folder with That String Name
- .BAT file to move files into folders and subfolders by filename... can't get subfolders to work
Any tips, comments, or helpful hints would be greatly appreciated! This is my first time trying to make a batch file. Thanks!