save single video in single folder.. having 200 videos in a folder

조회 수: 2 (최근 30일)
Irfan Hussain
Irfan Hussain 2020년 3월 20일
댓글: Irfan Hussain 2020년 3월 25일
hello all, i have 200 videos in a folder.. i want to send one video to one new folder..
means want to get 200 new folders with different names which having single video in each..
required code
thanks

답변 (1개)

Ameer Hamza
Ameer Hamza 2020년 3월 20일
편집: Ameer Hamza 2020년 3월 20일
This code will work for all the video files with extension .mp4. If the extension is something else, then change the first line.
files = dir('*.mp4');
for i=1:numel(files)
current_path = fullfile(files(i).folder, files(i).name);
new_folder = fullfile(files(i).folder, files(i).name(1:end-4));
new_path = fullfile(files(i).folder, files(i).name(1:end-4), files(i).name);
mkdir(new_folder);
movefile(current_path, new_path, 'f')
end
  댓글 수: 10
Irfan Hussain
Irfan Hussain 2020년 3월 21일
편집: Irfan Hussain 2020년 3월 21일
first video form folder 1 and first video of folder 2 (the output like that)

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by