Rename file using multiple drop downs (app designer)
Mostrar comentarios más antiguos
I have .m code that executes an app made in App Designer. A button in the app saves a file as "TestData.csv" in a specified folder. I would like to add multiple dropdowns to the GUI with descriptions, and then a rename button that renames the file according to the selections in the drop down. The addition to the GUI would look something like this:

The goal is to have matlab locate the file named "TestData.csv" and rename it to "Description1_Description2_Description3_Description4.csv". Is this possible? Here's what I have so far. What I cant figure out is how to string together the event.Values and rename the file with the selected drop downs. Not sure if movefile is the correct command here.
function Rename_Data_Callback(app, event)
app.Description1.Value = event.Value;
app.Description2.Value = event.Value;
app.Description3.Value = event.Value;
app.Description4.Value = event.Value;
%some sort of code that creates the new name with '_' between each value
movefile C:\Users\Desktop\TestData.csv C:\Users\Desktop\NewName.csv
end
4 comentarios
Garrett Craig Porter
el 12 de Jul. de 2022
Editada: Garrett Craig Porter
el 12 de Jul. de 2022
dpb
el 12 de Jul. de 2022
In both of those code snippets the line
movefile C:\Users\Desktop\TestData.csv C:\Users\Desktop\rename.csv
is using command syntax, not function syntax, so both file names are literal character strings as written.
You need something like
movefile(app.OriginalFileName.Value, app.NewFileName.Vale)
where the two variables are the content of the text boxen you need. It would be far simpler to write code if you were to create the values to catenate as an array; then compose or join will work nicely. Consider fullfile to build fully-qualified file names.
Garrett Craig Porter
el 12 de Jul. de 2022
Rik
el 13 de Jul. de 2022
You should post your solution as an answer. That way people with a similar question can see the solution.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Develop Apps Using App Designer en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!