-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchangeNames.sce
More file actions
30 lines (22 loc) · 915 Bytes
/
Copy pathchangeNames.sce
File metadata and controls
30 lines (22 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//script to rename multiple files in a new directory (copy, no delete)
//init
clear;
WRK_PATH = "C:\Users\germain.faity\Documents\STAPS\Doctorat\2 - Expériences\Expe2_OPTIMOD\Data & pretest\2- EXPE NOVEMBRE 2021\DATA";
oldNames_PATH = fullfile(WRK_PATH,"delsys_CSV_oldNames");
newNames_PATH = fullfile(WRK_PATH,"delsys_CSV_newNames");
//list files to rename
oldNames_all = listfiles(oldNames_PATH);
//get names and copy in a loop
for iName = 1:size(oldNames_all,1)
//old name
oldName = oldNames_all(iName);
oldFname = fullfile(oldNames_PATH,oldName);
//new name
oldNameInParts = strsplit(oldName,"_");
newName = oldNameInParts(1)+"_"+oldNameInParts(2)+" - D - "+strcat(oldNameInParts(3:$),"_");
newFname =fullfile(newNames_PATH,newName);
//get data in old file
datatxt = mgetl(oldFname);
//put data in new file
mputl(datatxt, newFname);
end