how to process multiple video files from a folder
Afficher commentaires plus anciens
I am in the process of processing numerous video files from a folder, so I need a sample support for processing one video file at a time. I am using the following snippet, but I am getting stuck with the following additional parameter when I look at the file name, which is halting my progress. Any assistance would be greatly appreciated.
folder = 'C:\Video_file\';
files = dir(folder)
files.name
numel(files.name)
ans =
162 % on my windows system
I see followig output
files.name
ans =
'.' % this is NOT required
ans =
'..' % this is NOT required
ans =
'dummy1.avi'
ans =
'dummy2.avi'
Thank you very much.
4 commentaires
Stephen23
le 21 Août 2023
By far the simplest approach is to specify the filename (using wildcards as required) and fileextension:
F = 'C:\Video_file\';
S = dir(fullfile(F,'*.avi'))
Life is Wonderful
le 21 Août 2023
numel(S.name) % this will throw an error if S has zero/multiple elements.
"I want to loop through the files one by one"
You can simply loop over the elements of S:
S = dir(..);
for k = 1:numel(S)
F = fullfile(S(k).folder,S(k).name);
% do whatever you want with filename F
end
Life is Wonderful
le 22 Août 2023
Réponses (2)
Chetan Bhavsar
le 21 Août 2023
files = dir('C:\Video_file\*.avi')
1 commentaire
Life is Wonderful
le 22 Août 2023
Image Analyst
le 21 Août 2023
1 vote
This is one of the most common FAQ questions, so see the FAQ:
1 commentaire
Life is Wonderful
le 22 Août 2023
Catégories
En savoir plus sur Startup and Shutdown dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!