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

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 日

1 投票

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 日
Thank you Hamaza... code works great
Ameer Hamza
Ameer Hamza 2020 年 3 月 21 日
Glad to be of help.
Irfan Hussain
Irfan Hussain 2020 年 3 月 21 日
Can you please send me a code of having 5 folders which have 200 videos in each folder.. make a new folder which have 5 videos form one each of the folder... means new folder having video 1 form folder one, video 1 form folder 2 , video 1 form folder 3, video 1 of folder 4 , video 1 form folder.. at last we get 200 new folders and each have 5 video... basically i work to make multiple camera dataset.. i work manually, much time consuming..
thanks
Ameer Hamza
Ameer Hamza 2020 年 3 月 21 日
Does all the video files in each folder have same name?
Irfan Hussain
Irfan Hussain 2020 年 3 月 21 日
No... having different names
Ameer Hamza
Ameer Hamza 2020 年 3 月 21 日
Gives structure of five folders. How do you decide which 5 video files should go in one folder.
Irfan Hussain
Irfan Hussain 2020 年 3 月 21 日
Videos folder 1
Irfan Hussain
Irfan Hussain 2020 年 3 月 21 日
Videos folder 2... rest of 3 folders having also differents names
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)
Irfan Hussain
Irfan Hussain 2020 年 3 月 25 日
Walter Roberson

サインインしてコメントする。

カテゴリ

ヘルプ センター および File Exchange で Get Started with MATLAB についてさらに検索

質問済み:

2020 年 3 月 20 日

コメント済み:

2020 年 3 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by