This is the last line of my script. now I want to add some new line for copy selected files in to the folder which folder is created form the newName variable.
Example: I am in a folder name Label 1
After I run the JScript, 2 new folder has been created, named of that folder is Label 2\Label 3\ I use READAUTO argument so I think after run my JScript my sourcetab path will be Label 1\Label 2\Label 3\
Now I want to add cmd.RunCommand("Copy"); Line for copy some selected files into the Label 3 folder. But The file has been copied in to Label 1 Folder.
So now I have to use something code for pass the path of Label 3 folder to the Copy command. Then the selected file will copied into the Label 3 folder.
Here is my Script:
function OnClick(clickData)
{
var eSel = new Enumerator(clickData.func.sourcetab.selected);
var getfoldername = eSel.item().realpath.filepart;
var re = /\s\([0-9]+?\)\.(.*)/;
var regfolder = getfoldername.replace(re, "");
var cmd = clickData.func.command;
cmd.SetSourceTab(cmd.desttab);
cmd.deselect = false;
var folderName = regfolder;
var matches = folderName.match(/^[^.]+/);
if (matches.length != 1) { return; }
var newName = matches[0] + ' Covers';
cmd.RunCommand('CreateFolder NAME="' + regfolder + '/' + newName + '" READAUTO');
cmd.RunCommand ('Copy');
}
Which part are you actually having trouble working out?
Going back to your first post, if you understand both the lines you have there then the answer should be obvious. You're already passing the folder + subfolder you want to create to the CreateFolder NAME argument. You just want to do the same thing to the Copy TO argument. At least if I have understood correctly.
But It's show a error massage like this screen shot and create a folder named NAME, but it does not give any error in to the error log, So I don't understand what is my problem in here, is there any Syntax I missing?
The Copy command can create a destination folder, but it's done like this:
Copy HERE CREATEFOLDER="Subdir1\Subdir2"
That would create Subdir1\Subdir2 under the current folder and copy the files into it.
(The Copy command has a CREATEFOLDER argument. This is not running the CreateFolder command on the same line as the Copy command. You can't do that kind of thing. It's just a command and another command's argument that happen to have the same name.)
But the approach you had at the start would also work. You can run a command to create the folder:
CreateFolder NAME="Subdir1\Subdir2"
And then a second command to copy the files into that folder:
Thanks Leo for the informative reply. you have clear me a big confusion, I had think CREATEFOLDER and CreateFolder both are same. Now I am clear CreateFolder is a command as like Copy but CREATEFOLDER is a argument, not a command.
but Steel my code doesn't copy the file, It's don't show any error also.
Here is my first command where I use CreateFolder command for Creating 2 of my Folders with this
This Line works fine no problem at all.
after this line I have add This Line for copy the selected files into the 2nd folder which is created from newName variable. But It's doesn't work.
I have 1 more problem. I have to copy the first file in to folder 1 which is created by regfolder variable. in the Standard function I was used @firstfileonly for mark up the first file, How to mark up the first file only in the JScript?
If any one wants to try here is my total code:
function OnClick(clickData)
{
var eSel = new Enumerator(clickData.func.sourcetab.selected);
var getfoldername = eSel.item().realpath.filepart;
var re = /\s\([0-9]+?\)\.(.*)/;
var regfolder = getfoldername.replace(re, "");
var cmd = clickData.func.command;
cmd.SetSourceTab(cmd.desttab);
cmd.RunCommand('Set Focus=Toggle');
cmd.ClearFiles();
cmd.deselect = false;
var cmd = clickData.func.command;
var folderName = regfolder;
var matches = folderName.match(/^[^.]+/);
if (matches.length != 1) { return; }
var newName = matches[0] + ' Covers';
cmd.RunCommand('CreateFolder NAME="' + regfolder + '/' + newName + '" READAUTO');
cmd.RunCommand('Copy TO="' + regfolder + '/' + newName + '"');
}
When I run the script the two folder will create and read auto will work, after that nothing happened, no error log, but the copy to command does not work also.
Hi My Dear Leo!
Can you tell me what is wrong in this code? Why does the Copy TO command paste the file into Label 3 Folder?
I already delete this line from the code cmd.ClearFiles(); but steel it's not worked
Sorry, I don't have time to help you every five minutes. I suggest breaking the problem down into something more simple, and trying to understand the building blocks you are using, instead of just putting them together and then asking us to do everything for you when they don't quite work.