I can't for the life of me work out how to do this.
The script is given to a button. When the button is clicked it should:
- Create a folder in the current dir called SS, and a subfolder of the current date, in the format YY MM DD.
- It should then move all the selected files to the newly created dir.
The folder is created, but no files are copied. When the folder is created, focus is shifted to the new folder so maybe that has something to do with the problem?
This is my code:
function OnClick(clickData) {
var tab = clickData.func.sourcetab;
var cmd = clickData.func.command;
var currentTime = new Date();
var year = currentTime.getFullYear() % 100;
var month = (currentTime.getMonth() + 1).toString();
var day = currentTime.getDate().toString();
// Ensure month and day are two digits
if (month.length < 2) month = '0' + month;
if (day.length < 2) day = '0' + day;
var pathToCreate = tab.path + "\\SS\\" + year + " " + month + " " + day;
// Create the folder
cmd.RunCommand('CreateFolder NAME="' + pathToCreate + '" READAUTO');
// Move selected files to the newly created folder
if (tab.selected_files.count > 0) {
// Format the path for Windows
cmd.RunCommand('Copy MOVE TO="' + pathToCreate)
}
}