How can I copy multiple files to another folder than current folder?

Hi, I want to move multiple txt files (all starting with rp_aS) to another folder than the current folder of the files (not a subfolder). If I use destdir = [path where I want my files to go]
copyfile rp_aS* destdir
matlab makes a new subfolder called destdir in my current folder. How do I copy all these files to another folder outside of the current folder (i.e., where destdir refers to).
Thanks in advance!

 採用された回答

awezmm
awezmm 2018 年 11 月 2 日

0 投票

Try using the fullpath to the new folder. On mac it begins something like /Users/blahblahblah....

5 件のコメント

Elien Bellon
Elien Bellon 2018 年 11 月 2 日
Thank you! However, to make different subfolders for every subject I have, I have to manually adjust this path for every subject. My dest dir had a num2str(SubjectID) to solve this problem. Can I add something like that in the fullpath?
awezmm
awezmm 2018 年 11 月 2 日
編集済み: awezmm 2018 年 11 月 2 日
Are all the SubjectIDS in an array something like [1001 1002 1003]? or are they in a different format
Elien Bellon
Elien Bellon 2018 年 11 月 2 日
I run the script for every participant separately, so it is just one number, which I indicate at the top of the script as "SubjectID = 13" for subject 13 for example
awezmm
awezmm 2018 年 11 月 2 日
編集済み: awezmm 2018 年 11 月 2 日
First pick where you want all the new folders to save to. Lets say you always want them to always go to the Desktop. And lets say you have already defined your new destdir.
%Get the full path of JUST your desktop
outside_dir = '/Putyour/fullpath/todesktop/inhere'
%To make variable changing full file path
custom_fullpath = fullfile(outside_dir, destdir)
copyfile rp_aS* custom_fullpath
Let me know if you need any more help
Elien Bellon
Elien Bellon 2018 年 11 月 2 日
編集済み: Elien Bellon 2018 年 11 月 2 日
Oh no, this makes another subfolder named "Custom_fullpath"

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeFile Operations についてさらに検索

質問済み:

2018 年 11 月 2 日

編集済み:

2018 年 11 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by