I have made a new command to move new sound files silently (without having to open the source "Download" folder). I wonder, if it's possoble to run those files through some sort of "automatic" rename presets, so that they would
then run another rename (@NoDeselect Rename REGEXP PATTERN="(.)(_|.| )(.)(.)(.*)#" TO="\1 \3\4\5")
run one of my custom renames¹
¹ (In the new rename editor, i can't find a way to create a new rename preset, where i could add my custom rename to that list. Isn't it possible somehow?)
I'm also not sure, if i would select the files in the source folder, & do the renaming there, or to copy move it to the destination, to complete the task. Maybe the first way would be better?
The Rename tool can move things as well. To do so you set the new name to a full path instead of just a name, and it will do the rest.
I use this myself to rename Opus installers to include version information, and at the same time move them to the folder I store them in. Here's the rename script:
(The end is the most relevant part here, but I'll include the whole script for completeness.)
[code]Option Explicit
Function OnGetNewName ( ByRef GetNewNameData )
OnGetNewName = False ' No rename if we exit early.
If GetNewNameData.item.is_dir Then
Exit Function
End If
Dim nameRemain
nameRemain = GetNewNameData.item.name
If UCase(Left(nameRemain,12)) = "DOPUSINSTALL" Then
nameRemain = Mid(nameRemain,13)
Else
Exit Function
End If
If UCase(Right(nameRemain,4)) = ".EXE" Then
nameRemain = Left(nameRemain,Len(nameRemain)-4)
Else
Exit Function
End If
Dim langString
If Len(nameRemain) = 0 Then
langString = ""
ElseIf Len(nameRemain) > 1 And Left(nameRemain,1) = "-" Then
langString = " - " & Right(nameRemain,Len(nameRemain)-1)
Else
Exit Function
End If
If GetNewNameData.item.metadata <> "exe" Then
Exit Function
End If
Dim verString
verString = GetNewNameData.item.metadata.exe.prodversion
Do While Right(verString,2) = ".0"
verString = Left(verString, Len(verString)-2)
Loop
Dim majorVersion
majorVersion = Left(verString,2)
OnGetNewName = "D:\tools\Directory Opus\Opus " & majorVersion & "\DOpusInstall - " & verString & langString & ".exe"
End Function[/code]
The buttons above the list of presets let you save a new preset. The Save icon is a menu with a Save As item inside it.
Sorry, but i don't understand the details. I could set a path, ok, but how could i include all three steps, which are separate rename actions. How could i chain them into one command?
The saving thing, i have to select something, like "first_steps.pdf", to get the advanced rename button activated, but i want to make a general button, not for a certain single file. Suppose, i choose some rename function, i want to change, how can i place stuff like this (don't mind the code, i know it's note very elegant )?
@NoDeselect
Rename MATCHCASE REGEXP PATTERN="(.)\bThe\b(.)#" TO="\1the\2" @NoDeselect
rename pattern " Cd " to " CD " findrep @NoDeselect
rename pattern " Cd" to " CD" findrep @NoDeselect
rename pattern "Dvd" to "DVD" findrep @NoDeselect
rename pattern " Dvd " to " DVD " findrep @NoDeselect
rename pattern "(The" to "(the" findrep @NoDeselect
rename pattern " and " to " & " findrep @NoDeselect
rename PATTERN="[" TO="(" FINDREP
rename PATTERN="]" TO=")" FINDREP @NoDeselect
rename pattern " _ " to " & " findrep @NoDeselect
rename pattern "´S" to "´s" findrep
I was looking for something like "-> New -> New rename preset", then some kind of yet empty area, to paste in that code. I guess, i don't understand the concept of the rename presets quite well.
I don't think you can use commands in the Rename tool. Simply copy your code into a button. Will work just as well, only downside being the missing preview.
Copy this to one of your toolbars:
<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" textcol="none">
<label>Rename for abr</label>
<tip>Change the names of selected files and folders</tip>
<icon1>#rename</icon1>
<function type="normal">
<instruction>@nodeselect</instruction>
<instruction>Rename MATCHCASE REGEXP PATTERN="(.*)\bThe\b(.*)#" TO="\1the\2"</instruction>
<instruction>Rename PATTERN " Cd " to " CD " FINDREP</instruction>
<instruction>Rename PATTERN " Cd" to " CD" FINDREP</instruction>
<instruction>Rename PATTERN "Dvd" to "DVD" FINDREP</instruction>
<instruction>Rename PATTERN " Dvd " to " DVD " FINDREP</instruction>
<instruction>Rename PATTERN "(The" to "(the" FINDREP</instruction>
<instruction>Rename PATTERN " and " to " & " FINDREP</instruction>
<instruction>Rename PATTERN="[" TO="(" FINDREP</instruction>
<instruction>Rename PATTERN="]" TO=")" FINDREP</instruction>
<instruction>Rename PATTERN " _ " to " & " FINDREP</instruction>
<instruction>Rename PATTERN "´S" to "´s" FINDREP</instruction>
</function>
</button>
Your code now looks pretty much, like my own, where my example was derived from. My idea was something similar to the different filters, we can already use. Maybe some sort of "rename aliases" would be a good idea, so we could build different processing chains using simple modules in a row. It is almost possible right now, but the problem is to keep it in sync, reselecting the files after pass 1, etc.
I'd like to explain the idea a bit more. In my old rename toolbar i have function no.1, "insert a dash", which can either be clicked directly, or triggered by Ctrl-Win-Alt-1. The next button is a Regex, which inserts two spaces around a dash, using Ctrl-Win-Alt-2, the third button removes dots or underscores, using Ctrl-Win-Alt-3, etc.
Now, & this isn't possible at the moment through Opus' standard dialog (but maybe through scripting techniques), but if we had some extra field "command alias", i could call them ren_InsDash, ren_spaces, & ren_removeDots.
So, a button running
ren_InsDash ren_spaces ren_removeDots
would consecutively run those commands, waiting for each one to finish, of course.
Can the raw Rename command do this (move things as well as rename) without invoking the tool? If so, can you give me an example please? Let's say I have a file C:\test.log and I want to rename to test1.log and move to c:\logs.
Can the raw Rename command do this (move things as well as rename) without invoking the tool? If so, can you give me an example please? Let's say I have a file C:\test.log and I want to rename to test1.log and move to c:\logs.