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

21 ビュー (過去 30 日間)
Stefan
Stefan 2018 年 1 月 30 日
編集済み: Stefan 2018 年 1 月 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 Center および File ExchangeFile Operations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by