MATLAB Answers

Renaming a file the same as a variable

7 views (last 30 days)
Tyler Murray
Tyler Murray on 3 Oct 2016
Commented: Tyler Murray on 3 Oct 2016
I am trying to rename a file the same as a variable. The variable obviously will be string, its just so I can make my program even more automated. For example :
x = 'RenameTest'
movefile('Original.txt', '%s.txt', x)
That code doesn't work but is this possible to do?

Sign in to comment.

Accepted Answer

dpb on 3 Oct 2016
As written, just
movefile('Original.txt', [x '.txt'])
More general and where you were probably trying to head would be something like
where oldfile is a string variable containing the original name.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!