I'm trying to programmatically rename a file in the working directory from a = 'temp.txt' to b = 'hello.txt'. How would you suggest doing so? Is there an easy file renaming function in MATLAB?
views:
1185answers:
2Yes, that is what I ended up doing.
stanigator
2009-08-14 05:03:30
+2
A:
Here's a list of a few solutions:
- Use the MOVEFILE function (as suggested by mtrw).
Use the SYSTEM function to execute an operating system command. For example (on Windows):
system('rename temp.txt hello.txt'); system(['rename ' a ' ' b]); % If the file names are stored in stringsUse the shell escape operator (
!) to invoke a system command. For example (on Windows):!rename temp.txt hello.txtIf the file names are stored in strings, you would need to use EVAL:
a = 'temp.txt'; b = 'hello.txt'; eval(['!rename ' a ' ' b]);
gnovice
2009-08-14 01:31:32