Old 07-13-2015, 12:47 AM   #1
syntetic
Human being with feelings
 
syntetic's Avatar
 
Join Date: May 2014
Posts: 160
Default Duplicate tracks + smart rename script(EEl)

Maybe it is possible to make a script simpler but I am not a programmer and the script works



Duplicate tracks + smart rename (0.9):
PHP Code:
function namebyvstiname()
(
 
TrackFX_GetFXName(track0#buf);
selected_tracks_count CountSelectedTracks(0);
0;
  
loop(selected_tracks_count
  (
track GetSelectedTrack(0i)) ? (
    
vsti_id TrackFX_GetInstrument(track);
////Get VSTi name
   
TrackFX_GetFXName(trackvsti_id#buf);
   
lenvstname=strlen(#buf);
   
while (str_getchar(#buf, lenvstname, c) != 40) // count down from end to find "(" char
   
(
   
lenvstname=lenvstname-1// count down from end
      
);
 
str_setlen(#buf,lenvstname-1);
   
name=GetSetMediaTrackInfo_String(track"P_NAME",#trn, 0);
   
emptyname=strcmp("",#trn);
   
emptyname==? (
   
GetSetMediaTrackInfo_String(track"P_NAME",#buf, 1);
   
trl=trl+1;
   );
); 
// 
+= 1
); 
// end loop vstid


//////////////////////////////////////
);




function 
duplicatetracks()
(


seltrackscount1=CountSelectedTracks(0);
// Dupliacate tracks
Main_OnCommand(400620);

// Unselect all items
Main_OnCommand(402890);

///Go next track (mcp) 
seltrackscount1==? (

//go to next track (leaving other tracks selected) 
Main_OnCommand(402870);
);

track GetSelectedTrack(00);
name GetSetMediaTrackInfo_String(track"P_NAME"#current_track_name, 0);

// FIND "#" (sharp)

len=strlen(#current_track_name);

getchar=str_getchar(#current_track_name,0,c);
);// end function duplicate track



///////////////////////////////////////////// Rename empty track
function renameemptytrack()
(
seltrackscount1=CountSelectedTracks(0);
ei=0;
loop(seltrackscount1,
track GetSelectedTrack(0ei);
name GetSetMediaTrackInfo_String(track"P_NAME"#current_track_name2, 0);
emptyname=strcmp("",#current_track_name2);
#unnamed="unnamed";
emptyname==? (

track GetSelectedTrack(0ei);
GetSetMediaTrackInfo_String(track"P_NAME"#unnamed, 1);
);
ei=ei+1;
);
);
//////////////////////////////////////////////////////////
///////////////////////////////////////////// Add "#1" for second track copy
function add_n1()
(
seltrackscount=CountSelectedTracks(0);
w=0;


loop(seltrackscount,
track GetSelectedTrack(0w);
name GetSetMediaTrackInfo_String(track"P_NAME"#current_track_name, 0);
len=strlen(#current_track_name);

while (str_getchar(#current_track_name, len, c) != 35) // count down from end to find "#" char.
    
(
      
len=len-1// count down from end
     
    
);

///
w=w+1;
len>=sharpsymbol=1;
len<sharpsymbol=0;
sharpsymbol==? (


strncat(#current_track_name," #1",999);
GetSetMediaTrackInfo_String(track"P_NAME"#current_track_name, 1);
);
);
//////////////////////////////////////////////////////////////////////
);//end func add_n1


function changetracknamenumber()
(
i=0;
loop(seltrackscount,
name GetSetMediaTrackInfo_String(track"P_NAME"#current_track_name2, 0);
len=strlen(#current_track_name);
while (str_getchar(#current_track_name, len, c) != 35) // count down from end to find "#" char.
    
(
      
len=len-1// count down from end
     
    
);
len>=sharpsymbol=1;
sharpsymbol==? (

//Change track name number

seltrackscount=CountSelectedTracks(0);


track GetSelectedTrack(0i);
name GetSetMediaTrackInfo_String(track"P_NAME"#current_track_name, 0);
len0=strlen(#current_track_name);
len1=strlen(#current_track_name);
while (str_getchar(#current_track_name, len1, c) != 35) // count down from end to find "#" char.
    
(
      
len1=len1-1// count down from end
     
    
);
countdigits=len0-len1-1;

//convert count of digits into string
sprintf(#strcd, "%d", countdigits);
getchard=str_getchar(#strcd,0,c);


//expresion for find
   #gettracknum="%0s*%0s";
   
str_setchar(#gettracknum,5,getchard,c);
   
match(#gettracknum, #current_track_name, LTS_n1, #tracknum_str);
//convert stringtracknum to int
   
match("%d"#tracknum_str, tracknum_d );
//tracknamenumber+1
   
tracknum_d=tracknum_d+1;
//convert trackname_num to string
   
sprintf(#newtracknum, "%d", tracknum_d);

//cut track num
   
str_setlen(#current_track_name,len1+1);

   
strncat(#current_track_name,#newtracknum,999);
   
GetSetMediaTrackInfo_String(track"P_NAME"#current_track_name, 1);
);
i=i+1;
);
);
///////////////////////////////////


namebyvstiname();

duplicatetracks();

renameemptytrack();

add_n1();

changetracknamenumber(); 

Last edited by syntetic; 07-24-2015 at 10:46 AM.
syntetic is offline   Reply With Quote
Old 07-13-2015, 01:25 AM   #2
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,070
Default

Nice to see your progress in scripting :P

Still no Lua in your Radar ? Strings operations tends to be simpler.
X-Raym is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 07:12 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.