//Random Music Copier
/*
How it works:
-Copies user-defined random (shuffled) music to another location (E.g. USB stick)
-Remembers previous list of files, so that you don't copy same files.
How? Using comments, Copied/Uncopied files are marked as "Copied"/"NotCopied" respectively.
-Option to delete older files from destination before copying new set of random files.
WARNING: Since it uses comments you will lose your old comments from source folder. Check this before you use.
*/
Code: Select all
//Random Music Copier
/*
How it works:
-Copies user-defined random (shuffled) music to another location (E.g. USB stick)
-Remembers previous list of files, so that you don't copy same files.
How? Using comments, Copied/Uncopied files are marked as "Copied"/"NotCopied" respectively.
-Option to delete older files from destination before copying new set of random files.
WARNING: Since it uses comments you will lose your old comments from source folder. Check this before you use.
*/
//Music to copy to (don't add trailing \)
$MusicDestination="D:\newlocation";
//Music to copy from (don't add trailing \)
$MusicSource="D:\Music";
//Song extensions. Add more extensions (separated by ;) if you want.
$MusicExtensions= "*.mp3;*.ogg";
//Set random number of files to copy
$RandomNumber=20;
//Option to delete old files from Music destination before copying new ones
IF (confirm ("Delete files in ""$MusicDestination\"" first?<crlf><crlf>OK=Delete files.<crlf>Cancel=Keep files.")==1){
//Delete by moving files into recycle bin but without any prompt
delete 1,0, "$MusicDestination\*";
}
ELSE{
//nothing
}
//Show files in music source folder and all its branches
goto "$MusicSource\?$MusicExtensions /r";
//Filter previously copied files
selfilter """Copied""", ,"comment";
//Invert selection
#252;
//Comment files as NotCopied
comment NotCopied;
//Show all files "NotCopied" files
goto "$MusicSource\?comment:NotCopied /r";
//Above code can be improved if XY allowed this: goto "$MusicSource\?comment:!Copied /r" (i.e. show all files except comment "Copied")
//Count files in MusicSource folder
$countsource = getinfo ("CountItems");
//If no random files left, option to reset comments and end script
IF ($countsource == 0){
IF (confirm ("No more random songs left in ""$MusicSource"",<crlf>Reset comments?")==1){
goto "$MusicSource\?$MusicExtensions /r";
//Select all files
sel a;
//Reset or remove comments
comment;
}
ELSE{
goto "$MusicSource\?$MusicExtensions /r";
}
//Terminate script
end (1);
}
//Sort files randomly
#331;
//If random number > source files, select all files.
IF ($RandomNumber>$countsource){
$RandomNumber=$countsource;
}
//Select files from 1 to randomnumber
sel 1, $RandomNumber;
//Comment selected files to "Copied"
comment Copied;
//focus list
focus;
//Using backupto instead of copyto to overcome similar file names such as Track-01, which will be suffixed to Track-01-01,Track-01-02 etc.
backupto "$MusicDestination",,4;
goto "$MusicDestination";
XYplorer Beta Club