How to rename a file with a string from user input?

2 次查看(过去 30 天)
Hi,
I would like to use a string from a text in prompt and then use movefile to rename a pdf file. Unfortunately, I can't figure out how to use the string for the file name. I would really appreciate your help.
Thanks, Stefan

回答(1 个)

KSSV
KSSV 2018-1-30
prompt = 'Give name of file:' ;
str = input(prompt,'s') ;
Now use str
  1 个评论
Stefan
Stefan 2018-1-30
编辑:Stefan 2018-1-30
Thanks for your answer. My code still doesn't work:
a ='T:\...\default.pdf';
newName = str;
movefile( a, newName );

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by