Remove extensions from filename and other letters

ia have file called "filenameXCD.avi"

In ms-dos example:
PROGRAM.exe -a -b -c "c:\filenameXCD.avi" "c:\filename_CD.avi"

when in Opus i select file "filenameXCD.avi", i want to execute this program like this, i want get commandline like this...
And remember - "XCD" is only in this line, i want use this button in other situations ("...123.avi", "...a7h.avi")

i want cut three characters (exact replace 3-rd) from filename from right side.

But i no ideas how i cat do this... :confused:

So, you want to replace the 3rd character from the right, whatever the filename is?

Filename003.txt
NameABC.doc
12000.txt

And you want to replace the 3rd character with an underscore (low line), whatever the filename is?

Filename_03.txt
Name_BC.doc
12_00.txt

As Christiaan said, it sounds like you want to replace the 3rd from right (not counting .avi) with something like a _ and then use that new name in a button command to send the new name to an external program?

For example say you have filenameXCD.avi selected in Opus.

But when it is all done you want to run a command something like:

PROGRAM.EXE filename_CD.avi

If so, try something like this:

@nodeselect Rename REGEXP PATTERN "(.*).(..\....)" TO "\1_\2" "C:\test\external program.exe" {F}

Note you may need to use {f} instead of {F} depending on what your external progam requires.

@LITWINCZUK:
It would help if you gave a brief description of what you are trying to do, like what the program does, etc etc.

@JohnZ and Christiaan:
I think he's not actually trying to rename the original file in Opus at all... I'm just reading this entire thread for the first time, and it seems (to me) after looking at this with a fresh pair of eyes that maybe he wants to select the fileXXX, and pass that filename along with a STRING 'based' on the filename to the external program... perhaps a transcoder or something that will actually be creating a new file using the STRING being passed?

If that is the case, I don't think you can kluge this sort of string manipulation using Opus even with Opus variables... probably have to use an external vbscript or something eh?

sorry for my poor english, i learn it myself...

When i done this work, i public new button - what reencode video with one-click with virtualdub :slight_smile:

I have a Nokia E61 phone, with installed SmartMovie. This is a video player. I want to create a command line to reencode avi files.

This button work correctly, but i want do to a little upgrade, but i have no idea how to do it..
PROGRAM FILE_IN FILE_OUT
like
PROGRAM "{f}" "{O|noext}_E61.avi"
i don't remember how use {f} and {o} to create "filenameDGEE"+".avi" extension

example:
{f}="d:\filenameDGEE.avi" - this will result a file created by virtualdub named "d:\filenameDGEE_E61.avi"

but.... how to create
PROGRAM "{f}" ????
to get "d:\filename_E61.avi" or "d:\filename_GEE.avi"

"{O|noext}_E61.avi" should work. If you have problems with Opus automatically adding quotes in the wrong places because of the prefix you're adding, add this line the top of the command:

@nofilenamequoting

That tells Opus not to add quotes automatically, so you only get the quotes which you add to the command yourself (which you have already added in your example).

[s]You can also use {O|ext} to insert the file extension (including the .), which might be useful if the command has to work with more than just .AVI files. For example,

"{O|noext}_E61{O|ext}"[/s]

Edit: After I tried this I realised that {O|ext} inserts a space before the extension, so it isn't useful in this example. The @nofilenamequoting is still worth a try, though.

Edit 2: {o|ext} (lower-case o) is fine, though, and there's a good reason not to use {O|ext} (upper-case o), which I'll explain in a proper reply.

as you see, this question is simple, but to do this is a little problem...

I find solution!

"{f}" {d}{o|noext}"_E61"{o|ext}

selected file:
"F:\TEMP\uTorrent\Pobrane\seriale\The Outer Limits\The Outer Limits - 2x01 - A Stitch In Time.avi"

After use on destination (used {d}) will be created file:
The Outer Limits - 2x01 - A Stitch In Time_E61.avi

"{f}" {o|noext}"_E61"{o|ext}

  • file will be created at same dir

[quote="LITWINCZUK"]I find solution!

{d}{o|noext}"_E61"{o|ext}[/quote]
That will insert some extra quotes into the name which could cause a problem, although most software will probably ignore them.

...but your idea made me realise that {o|ext} (lowercase o) works fine; it is only {O|ext} which inserts the space. Strange but true!

So you can simply use this to get an exact result (no extra spaces or quotes in the filename):

{O|noext}_E61{o|ext}

In your latest example, you are no longer REPLACING any characters in the 'filename' portion... just ADDING characters to the enf of the existing filenames, along with re-adding the extension.

Again, it seems like what you want to do is best accomplished by a script IF you want to REPLACE characters in the existing filename and send the resulting 'new' name as a string to VirtualDub.

If you're happy with simply ADDING characters to the end of the existing filename, then what 'exactly' is the problem with the latest button you've tried so far?

{d}{O|noext}_E61{o|ext}
result: error

{O|noext}_E61{o|ext}
result: error

{d}{O|noext}"_E61"{o|ext}
result: error

{O|noext}"_E61"{o|ext}
result: error

{o|noext}"_E61"{o|ext}
result: WORKING

Tested with files located on patch:
F:\TEMP\uTorrent\Pobrane\seriale\The Outer Limits
filename:
The Outer Limits - 2x12 - Inconstant Moon.avi

will be created file named: (i show file patch+file) (filename will be created as "The Outer Limits - 2x12 - Inconstant Moon.avi")
"F:\TEMP\uTorrent\Pobrane\seriale\The Outer Limits\The Outer Limits - 2x12 - Inconstant Moon.avi"

(also {o|noext}"_E61"{o|ext} working fine with with destination "F:\TEMP\uTorrent\Pobrane\seriale\The Outer Limits\The Outer Limits Episode Guide")

Big thanks to all for help me found a solution !!

Steje, i know what i adding a part of text - first of my question is still active.

This another problem what i have with this button what i creating now.

[quote="leo"][quote="LITWINCZUK"]I find solution!

{d}{o|noext}"_E61"{o|ext}[/quote]it is only {O|ext} which inserts the space. Strange but true!"[/quote]

And I have had many disaster of this extra space :angry:

Regards

And i have another question....

How to do....?

If i remember correctly, in Opus v6 or other version, program when i clicked on button, created a script on hardisk with command to execute (maybe only in ms-dos mode?) How to show command generated with this button?
Send command with >c:\Filename.txt ot something else?

[quote="LITWINCZUK"]{o|noext}"_E61"{o|ext}
result: WORKING

Tested with files located on patch:
F:\TEMP\uTorrent\Pobrane\seriale\The Outer Limits
filename:
The Outer Limits - 2x12 - Inconstant Moon.avi

will be created file named: (i show file patch+file) (filename will be created as "The Outer Limits - 2x12 - Inconstant Moon.avi")
"F:\TEMP\uTorrent\Pobrane\seriale\The Outer Limits\The Outer Limits - 2x12 - Inconstant Moon_E61.avi"
[/quote]
I made a small mistake..

I mentioned this to Jon @ GPSoft and after his explanation I think we've all been doing something silly. :slight_smile:

The command shouldn't be using {O} or {O|ext} at all.

{O} (upper-case O) is the same as {allfile$}, aka "Need all filenames (long)". It inserts the names of all files into a single line.

So if you had moo.mpg and cow.avi then {O|ext} would result in " .mpg .avi". That extra space at the start probably isn't wanted, but then the whole thing is inappropriate really.

You only want one name and one extension per line with this command, so {o|ext} (lower-case o) is the one to use, and that doesn't insert the space.

This is one of the reasons that I much prefer using the long versions of the command codes. It's immediately obvious what {allfile$} does, while {O} is cryptic and requires you to remember its meaning.

[quote="LITWINCZUK"]And i have another question....

If i remember correctly, in Opus v6 or other version, program when i clicked on button, created a script on hardisk with command to execute (maybe only in ms-dos mode?) How to show command generated with this button?
Send command with >c:\Filename.txt ot something else?[/quote]

Questions like that are best asked in a separate thread, but I can answer it quickly and hopefully save this thread from splitting in half. :slight_smile:

If you just want to see what the command is generating then there are two easy ways to do that.

One is to use the DopTest tool, which prints out its arguments.

Another is to switch the button to the MS-DOS type, add "echo " before each line, and add a "Pause" line (both without the quotes) to the end.

Thanks, Leo.

Tell me, why editing is disabled?

"You cannot edit your posts in this forum"

[quote="LITWINCZUK"]Tell me, why editing is disabled?

"You cannot edit your posts in this forum"[/quote]

That's answered in this FAQ: [Why can't I edit my posts?)