Wouldn't this be a job for rename macros nowadays?
Don't think it's possible to use clipboard data in rename macro.
But nowdays, maybe there is another way to do that.
I therefore specify, I want to rename the selection by adding the text from the clipboard (e.g. text from website) in front of the original names of the selected files.
Ctrl+Shift+V will paste clipboard data when doing a rename macro.
You can also use the Clipboard menu at the bottom of the Rename dialog to prefix existing names with the clipboard text.
ok, it works but not ideal in my case.
- I copied text from a web page, 1 or more words
- I select files in a folder
- I click on a button to insert the copied text at the beginning of the selected files.
There is no command to simulate this that I can add to button ?
There is ![]()
@nofilenamequoting
@nodeselect
Rename TO="{clip}{file}"
I was looking for that {clip} placeholder in here, couldn't remember its exact name.
Shouldn't it be right there somewhere or is it missing?
You can insert the clipboard with the Evaluator:
{=Clip()=}
So easy ![]()
I knew Opus could do everything.
Many thanks
I don't want to! I want to select the placeholder from the nice collection of things already there! o)
You seem to develop some kind of fetish for these Evaluator things, are you? o) I still haven't wrapped my head around them yet, I think I have issues with the syntax somehow, I don't know! o)
Yep, you got me... my guilty pleasure ![]()
Looks like {clip} is not supported yet, but it'd make sense to include it, right next to {date} and {time}.
When using:
@nofilenamequoting
@nodeselect
Rename TO="{clip}"
It renames the first selected file with the first line of CP then opens the rename GUI.
I want each selected items to be renamed using the corresponding line in CP.
Only the clipboard feature from the rename GUI works.
Can be done with an Evaluator Function button:
items = GetItems("s");
lines = Explode(Clip(), CRLF);
k = 0;
for (i = 0; i < Len(items); i++) {
f = ArrayGet(items, i);
p = ArrayGet(lines, k);
cmd = "Rename FROM=""" + f + """ TO=""" + p + """ IGNOREEXT";
// Output(cmd);
Run(cmd);
k++;
if (k >= Len(lines)) k = 0;
}
XML
<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" textcol="none">
<label>RenameFromClipboardEval</label>
<icon1>#newcommand</icon1>
<function type="eval">
<instruction>items = GetItems("s");</instruction>
<instruction />
<instruction>lines = Explode(Clip(), CRLF);</instruction>
<instruction>k = 0;</instruction>
<instruction />
<instruction>for (i = 0; i < Len(items); i++) {</instruction>
<instruction> f = ArrayGet(items, i);</instruction>
<instruction> p = ArrayGet(lines, k);</instruction>
<instruction> </instruction>
<instruction> cmd = "Rename FROM=""" + f + """ TO=""" + p + """ IGNOREEXT";</instruction>
<instruction> </instruction>
<instruction> // Output(cmd);</instruction>
<instruction> Run(cmd);</instruction>
<instruction> </instruction>
<instruction> k++;</instruction>
<instruction> </instruction>
<instruction> if (k >= Len(lines)) k = 0; </instruction>
<instruction>}</instruction>
</function>
</button>
@fred
Is there any relation between your question making use of "Rename" (standard DO command) and RenameFromClipboard (which is a specialized, custom script command this thread is about)?
RenameFromClipboard (this command here) is deprecated and was replaced by "RenameEx", please watch the first post about this.
RenameEx should be able to do what you want. You can also use lxp's Evalutator code or find a regular JScript variant of this in the forum, but you miss out on some convenience features built into RenameEx.
Happy Christmas.. o)
Thanks. It works. Great alternative to RenameEx.
The difference is:
RenameEx FROMCLIPrenames the file name and extension and support full undo.- Eval version keeps original extension and only renames the file name and the downside is it doesn’t support undo (only the last selected file).
Try
items = GetItems("s");
lines = Explode(Clip(), CRLF);
k = 0;
cmd = "";
for (i = 0; i < Len(items); i++) {
f = ArrayGet(items, i);
p = ArrayGet(lines, k);
cmd += "Rename FROM=""" + f + """ TO=""" + p + """" + CRLF;
k++;
if (k >= Len(lines)) k = 0;
}
// Output(cmd);
Run(cmd);
I'd still use the Renamer with the preview and better exception handling.
Thanks. I ended up writing this error proof eval version:
items = GetItems("s");
lines = Explode(Clip(), CRLF);
nLines= Len(lines);
nItems= Len(items);
nLoops = nLines < nItems ? nLines : nItems;
Output("RENAME FROM CP");
Output("nLines: " + nLines);
Output("nItems: " + nItems);
Output("nLoops: " + nLoops);
cmd = "";
for (i = 0; i < nLoops; i++) {
f = ArrayGet(items, i);
p = ArrayGet(lines, i);
cmd += "Rename FROM=""" + f + """ TO=""" + p + """ WHENEXISTS=skip" + CRLF;
}
// Output(cmd);
Run(cmd);
For the version that needs to keep original extension, replace line 18 with:
cmd += "Rename FROM=""" + f + """ TO=""" + p + """ IGNOREEXT WHENEXISTS=skip" + CRLF;
