Naming a file based on the folder name
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
So I have a script that can take all the images in a folder and stitch them together into an AVI movie file. It works great. Here's where I need some help.
The script tells ML to start in a root directory, it will look at all folders and subfolders, start in the first one, enter the subfolder, and take the images and create the AVI. Then it goes back out and enters any other subfolders and does the same, then goes back out to the root directory and goes to the next folder, and so on down the line until it runs out of folders to use.
The only thing I would like to do is to have MATLAB name the new AVI file this way: FolderName_SubFolderName_AVI
Any tips are appreciated.
2 commentaires
Azzi Abdelmalek
le 7 Août 2014
I don't understand what you've already done and what your are asking for.
Réponses (1)
Image Analyst
le 7 Août 2014
Try this:
folder = 'd:\all_tests\test1'; % Sample folder name.
[parentFolder, deepestFolder, ~] = fileparts(folder)
[parentFolder, folder1, ~] = fileparts(parentFolder)
baseFileName = sprintf('%s_%s_AVI.avi', folder1, deepestFolder)
fullFileName = fullfile(folder, baseFileName)
In command window:
parentFolder =
d:\all_tests
deepestFolder =
test1
parentFolder =
d:\
folder1 =
all_tests
baseFileName =
all_tests_test1_AVI.avi
fullFileName =
d:\all_tests\test1\all_tests_test1_AVI.avi
Also, see my demo, attached, where I recurse into all subfolders.
4 commentaires
Voir également
Catégories
En savoir plus sur File Operations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!