Uigetfile - Is there a neater way of moving my files?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
10B
el 28 de Sept. de 2015
Comentada: 10B
el 5 de Oct. de 2015
Hello Community,
After my script has run I want to do a little housekeeping and save various .mat, .jpg and .fig files to a specific file (that I create with user input slightly earlier in the script). At the moment I create the new folder with this:
mkdir(input('Enter new folder name (same as img count): ', 's'))
then when its time to save the .mat, .jpg and .fig to this newly created folder I use this code:
[filename, pathname, filterindex] = uigetfile( ...
{ '*.mat','MAT-files (*.mat)'; ...
'*.fig;*.fig','figures (*.fig)'; ...
'*.jpg;*.jpg','Jpgs (*.jpg)'}, ...
'Pick a file', ...
'MultiSelect', 'on');
to manually select the relevant .mat, .jpg and .fig files from the dialogue box and basically drag and drop them in the newly created folder and then close the dialogue.
This doesn't seem like a very efficient way of doing this - but I haven't managed to work out another way.
Does anyone have any suggestions on how to improve this workflow?
Regards,
10B.
0 comentarios
Respuesta aceptada
Image Analyst
el 28 de Sept. de 2015
In your script, set a desired destination folder and use fullfile to save them directly so that there is no need to move them.
desiredFolder = 'c:\whatever';
baseFileName = 'myApp.mat';
fullFileName = fullfile(desiredFolder, baseFileName);
Then do whatever you already to to save or create these files. If you don't use a folder, then they just save to the current directory and you have to move them like you're doing (but don't want to do).
15 comentarios
Bjorn Gustavsson
el 30 de Sept. de 2015
My suggestion is to scrap the regexp, you will sooner or later want to use the functionality on images that doesn't follow the current pattern (IMG_NNN.ext) and then it will break. Instead use the fileparts function - it will separate [the path-string and] the name and the extension regardless of what pattern it follows. Be lazy when possible.
Más respuestas (0)
Ver también
Categorías
Más información sobre Environment and Settings en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!