[gentoo-user] Dolphin and adding a option, if it exists.

12 views
Skip to first unread message

Dale

unread,
Oct 6, 2022, 12:50:04 AM10/6/22
to
Howdy,

This may not exist.  If not, oh well.  Sometimes when I'm moving files
with Dolphin, I need a added feature.  I tend to use split panes when I
copy or move files.  Quite often, I want to move files from one location
to another and the new file use the same name as the old file I'm
replacing.  What I *wish* I could do, move the file from one pane to the
other and drag the new file on top of the old file and it replace it
with the name of the old file.  As it is now, I have to bring up
properties, select the name of the file, while not including the
extension, and copy it, then close that window and open properties on
the new file, highlight the old name, paste new name, close window, copy
new file over and either delete old file or tell it to overwrite the
file.  Sometimes it has a different extension and I have to delete
instead. 

It would be a lot faster if I could just drag it on top of file I want
to replace and either it be configured to use name of old file for new
file or me select in a pop up what I want to do.  Basically, move and
drop instead of all the properties, copy, repeat with paste on new file
and then move and maybe delete a file as well.  I went to the services
window and looked for anything I could add but I didn't see anything
that would do what I describe but it could be a hidden feature of one
that isn't obvious. 

Has anyone ever seen something that does this?  While I use dolphin, I
may could use another tool if it has this feature. 

Thanks.

Dale

:-)  :-) 

Michael

unread,
Oct 6, 2022, 3:41:22 AM10/6/22
to
Perhaps I'm missing something ...

If the old file has the *same* name as the new file, the file manager will
warn you and ask you if you want to rename the new file so as it does not
overwrite the old file, or if you want to replace the old file.

If the old file has a different name, then the new file will be pasted in
without asking. In this case isn't it quicker to delete the file you want
replaced and then copy/move the new file over? Shift+Delete or right click -
'Delete' to delete it completely or just Delete/right click - 'Move to
wastebin' in case you delete the wrong file by mistake and want to recover it
later. BTW, pressing F2 after you select a file will allow you to rename it,
without having to dive into properties.
signature.asc

Michael

unread,
Oct 6, 2022, 4:00:06 AM10/6/22
to
On Thursday, 6 October 2022 08:52:04 BST Wol wrote:
> On 06/10/2022 08:33, Michael wrote:
> > On Thursday, 6 October 2022 05:39:59 BST Dale wrote:
> >> Howdy,
> >>
> >> This may not exist. If not, oh well. Sometimes when I'm moving files
> >> with Dolphin, I need a added feature. I tend to use split panes when I
> >> copy or move files. Quite often, I want to move files from one location
> >> to another and the new file use the same name as the old file I'm
> >> replacing. What I*wish* I could do, move the file from one pane to the
> >> other and drag the new file on top of the old file and it replace it
> >> with the name of the old file. As it is now, I have to bring up
> >> properties, select the name of the file, while not including the
> >> extension, and copy it, then close that window and open properties on
> >> the new file, highlight the old name, paste new name, close window, copy
> >> new file over and either delete old file or tell it to overwrite the
> >> file. Sometimes it has a different extension and I have to delete
> >> instead.
> >>
> >> It would be a lot faster if I could just drag it on top of file I want
> >> to replace and either it be configured to use name of old file for new
> >> file or me select in a pop up what I want to do. Basically, move and
> >> drop instead of all the properties, copy, repeat with paste on new file
> >> and then move and maybe delete a file as well. I went to the services
> >> window and looked for anything I could add but I didn't see anything
> >> that would do what I describe but it could be a hidden feature of one
> >> that isn't obvious.
> >>
> >> Has anyone ever seen something that does this? While I use dolphin, I
> >> may could use another tool if it has this feature.
> >>
> >> Thanks.
> >>
> >> Dale
> >>
> >> 😄 😄
> >
> > Perhaps I'm missing something ...
> >
> > If the old file has the*same* name as the new file, the file manager will
> > warn you and ask you if you want to rename the new file so as it does not
> > overwrite the old file, or if you want to replace the old file.
>
> This made me think. Some times the old tools are the best - maybe I
> ought to switch from Dolphin to Midnight Commander for my use case, and
> maybe you should too.
>
> Okay, it doesn't do exactly what you want, but the dance you want to do
> it will make it a lot easier ...
>
> Cheers,
> Wol

I just had a look in Dolphin configuration. Under General/Confirmations tab
you can select to disable asking for confirmation when you move files to
wastebin, or when you delete files of folders. Not sure if this is desirable,
as you could inadvertently delete a file without thinking first, but if you
are going to be deleting manually a lot of files, confirming this is something
you really want to do could become so repetitive you may want to disable it at
least for a while.
signature.asc

Wol

unread,
Oct 6, 2022, 4:00:06 AM10/6/22
to
On 06/10/2022 08:33, Michael wrote:
> On Thursday, 6 October 2022 05:39:59 BST Dale wrote:
>> Howdy,
>>
>> This may not exist. If not, oh well. Sometimes when I'm moving files
>> with Dolphin, I need a added feature. I tend to use split panes when I
>> copy or move files. Quite often, I want to move files from one location
>> to another and the new file use the same name as the old file I'm
>> replacing. What I*wish* I could do, move the file from one pane to the
>> other and drag the new file on top of the old file and it replace it
>> with the name of the old file. As it is now, I have to bring up
>> properties, select the name of the file, while not including the
>> extension, and copy it, then close that window and open properties on
>> the new file, highlight the old name, paste new name, close window, copy
>> new file over and either delete old file or tell it to overwrite the
>> file. Sometimes it has a different extension and I have to delete
>> instead.
>>
>> It would be a lot faster if I could just drag it on top of file I want
>> to replace and either it be configured to use name of old file for new
>> file or me select in a pop up what I want to do. Basically, move and
>> drop instead of all the properties, copy, repeat with paste on new file
>> and then move and maybe delete a file as well. I went to the services
>> window and looked for anything I could add but I didn't see anything
>> that would do what I describe but it could be a hidden feature of one
>> that isn't obvious.
>>
>> Has anyone ever seen something that does this? While I use dolphin, I
>> may could use another tool if it has this feature.
>>
>> Thanks.
>>
>> Dale
>>
>> 😄 😄
> Perhaps I'm missing something ...
>
> If the old file has the*same* name as the new file, the file manager will
> warn you and ask you if you want to rename the new file so as it does not
> overwrite the old file, or if you want to replace the old file.

Arve Barsnes

unread,
Oct 6, 2022, 4:20:04 AM10/6/22
to
This is probably a case of Dolphin not being a good tool, unless it
has a built-in command-line?
$ mv newfile oldfile
will overwrite the old file in place with the new file with the name
of the old file.

In my file manager, emelfm2 (sadly not in tree any more), which has a
built-in command-line there are at least two ways I could solve this.

1. Equivalent to your method
- Select old file, F2 (rename), ctrl+c, esc, select new file in other
pane, shift+F6 (move with rename), ctrl+v, enter

2. Equivalent to explicit command-line on the built-in terminal
- mv %f %F (referencing selected file(s) in the active and inactive
pane respectively)

I know there are many file managers with a built-in terminal, so maybe
others have similar possible solutions. I saw someone mention midnight
commander which I believe is one.

Regards,
Arve

Neil Bothwick

unread,
Oct 6, 2022, 8:50:04 AM10/6/22
to
On Thu, 6 Oct 2022 10:10:52 +0200, Arve Barsnes wrote:

> This is probably a case of Dolphin not being a good tool, unless it
> has a built-in command-line?
> $ mv newfile oldfile
> will overwrite the old file in place with the new file with the name
> of the old file.

And tab-completion makes this a lot quicker than renaming files in a file
manager.

> I know there are many file managers with a built-in terminal, so maybe
> others have similar possible solutions. I saw someone mention midnight
> commander which I believe is one.

Or you could use a drop-down terminal like Yakuake to give a terminal on
demand, whatever program you are using. Yakuake is for KDE, it wraps
Konsole, but there are GNOME-ish variants too, I wouldn't be without it.


--
Neil Bothwick

All things in moderation, ESPECIALLY moderation.

Neil Bothwick

unread,
Oct 6, 2022, 11:30:04 AM10/6/22
to
On Thu, 6 Oct 2022 17:19:09 +0200, Ramon Fischer wrote:

> And if you like Bash brace expansions; this one is sometimes quicker,
> than tab-completion and removing characters:
>
>     $ mv file.txt{,.bak}
>     file.txt.bak
>     $ mv file.txt,{bak,img}
>     file.txt.img
>     $ mv file.txt{img,}
>     file.txt

$ mv -b oldname newname

If newname exists, it is renamed with a ~ extension.

>
> -Ramon
>
> On 06/10/2022 14:45, Neil Bothwick wrote:
> >> This is probably a case of Dolphin not being a good tool, unless it
> >> has a built-in command-line?
> >> $ mv newfile oldfile
> >> will overwrite the old file in place with the new file with the name
> >> of the old file.
> > And tab-completion makes this a lot quicker than renaming files in a
> > file manager.
> >
>




--
Neil Bothwick

I'll never forget the 1st time I ran Windows, but I'm trying...

Dale

unread,
Oct 6, 2022, 1:50:03 PM10/6/22
to
Neil Bothwick wrote:
> On Thu, 6 Oct 2022 10:10:52 +0200, Arve Barsnes wrote:
>
>> This is probably a case of Dolphin not being a good tool, unless it
>> has a built-in command-line?
>> $ mv newfile oldfile
>> will overwrite the old file in place with the new file with the name
>> of the old file.
> And tab-completion makes this a lot quicker than renaming files in a file
> manager.
>

This is a option I haven't thought of.  The mv command is a good
thought.  Next time I have a lot of these to do, I'll try it.  It just
may work.  Plus, tab completion would be a nice bonus.


>> I know there are many file managers with a built-in terminal, so maybe
>> others have similar possible solutions. I saw someone mention midnight
>> commander which I believe is one.
> Or you could use a drop-down terminal like Yakuake to give a terminal on
> demand, whatever program you are using. Yakuake is for KDE, it wraps
> Konsole, but there are GNOME-ish variants too, I wouldn't be without it.
>
>

I look into Yakuake.  I've never heard of it before.  It's emerging and
I have to run to town to help a friend.

Thanks.

Dale

:-)  :-) 

Dale

unread,
Oct 7, 2022, 11:50:03 PM10/7/22
to
Dale wrote:
> Neil Bothwick wrote:
>> On Thu, 6 Oct 2022 10:10:52 +0200, Arve Barsnes wrote:
>>
>>> This is probably a case of Dolphin not being a good tool, unless it
>>> has a built-in command-line?
>>> $ mv newfile oldfile
>>> will overwrite the old file in place with the new file with the name
>>> of the old file.
>> And tab-completion makes this a lot quicker than renaming files in a file
>> manager.
>>
> This is a option I haven't thought of.  The mv command is a good
> thought.  Next time I have a lot of these to do, I'll try it.  It just
> may work.  Plus, tab completion would be a nice bonus.
>

I just got a couple dozen videos that I want to do what I described
with.  I used the -v option with mv plus double check in dolphin
afterwards and so far, it works nicely.  Tab completion makes it really
easy.  It's faster than all the properties window, copy, paste and all
that.  I might add, along with tab completion, I also use the highlight
and middle click on the mouse.  A faster way to copy and paste when
needed.  That's a nifty feature of Konsole.


>>> I know there are many file managers with a built-in terminal, so maybe
>>> others have similar possible solutions. I saw someone mention midnight
>>> commander which I believe is one.
>> Or you could use a drop-down terminal like Yakuake to give a terminal on
>> demand, whatever program you are using. Yakuake is for KDE, it wraps
>> Konsole, but there are GNOME-ish variants too, I wouldn't be without it.
>>
>>
> I look into Yakuake.  I've never heard of it before.  It's emerging and
> I have to run to town to help a friend.
>
> Thanks.
>
> Dale
>
> :-)  :-) 
>


I installed Yakuake and to me, it looks like Konsole but without the
menu part at the top.  Other than that, I don't see anything special.  I
kinda wish I had a terminal with dolphin or something.  I think there is
a way but right now, I'm getting the job done.  I'll look into that
later.  Pretty sure it is under the tool menu.

Thanks.

Dale

:-)  :-) 

Michael

unread,
Oct 8, 2022, 4:11:25 AM10/8/22
to
On Saturday, 8 October 2022 04:44:56 BST Dale wrote:

> I installed Yakuake and to me, it looks like Konsole but without the
> menu part at the top. Other than that, I don't see anything special.

Once Yakuake is running, F12 will open it in whichever virtual desktop you
happen to be and you can continue your work in the terminal within that
desktop. I'm not sure what other benefits it has.


> I
> kinda wish I had a terminal with dolphin or something. I think there is
> a way but right now, I'm getting the job done. I'll look into that
> later. Pretty sure it is under the tool menu.
>
> Thanks.
>
> Dale
>
> :-) :-)

Yes, look at Tools>'Focus Terminal Panel', or Ctrl+Shift+F4. I find this more
useful than Yakuake for my typical use case,[1] or more often I just use
Shift+F4 to open a new separate Konsole terminal in the same directory as
Dolphin happens to be.

[1] Often I go into a directory which I have already opened in Dolphin and
then run a series of commands in a terminal, without needing to refer back to
dolphin.
signature.asc

Dale

unread,
Oct 8, 2022, 4:20:04 AM10/8/22
to
Michael wrote:
> On Saturday, 8 October 2022 04:44:56 BST Dale wrote:
>
>> I installed Yakuake and to me, it looks like Konsole but without the
>> menu part at the top. Other than that, I don't see anything special.
> Once Yakuake is running, F12 will open it in whichever virtual desktop you
> happen to be and you can continue your work in the terminal within that
> desktop. I'm not sure what other benefits it has.
>

I think since I always have Konsole open and ready, it is easier for me
to use it.  If I rarely had Konsole open, then that might come in
handy.  I have Konsole with several tabs open and parked on desktop 3. 
It's stuck there at all times.  I have 18 virtual desktops and some have
specific programs on certain desktops.  Seamonkey web browser is always
on desktop 1.  Seamonkey email is on desktop 2.  The list goes on.  I'm
pretty organized in that way. ;-)


>> I
>> kinda wish I had a terminal with dolphin or something. I think there is
>> a way but right now, I'm getting the job done. I'll look into that
>> later. Pretty sure it is under the tool menu.
>>
>> Thanks.
>>
>> Dale
>>
>> :-) :-)
> Yes, look at Tools>'Focus Terminal Panel', or Ctrl+Shift+F4. I find this more
> useful than Yakuake for my typical use case,[1] or more often I just use
> Shift+F4 to open a new separate Konsole terminal in the same directory as
> Dolphin happens to be.
>
> [1] Often I go into a directory which I have already opened in Dolphin and
> then run a series of commands in a terminal, without needing to refer back to
> dolphin.

I have Konsole set to run su - when it opens so that messes up that.  It
opens and cd's to the directory but wants to run as root.  I guess I
could find a way to get a root Konsole another way but most of the time,
I need it as root anyway. On the rare occasion I need it as my user, I
just su dale and carry on. 


I will say this, using mv was much easier and faster than my old way a
bit ago.  Thanks Arve for that suggestion.  It's command line but it
works well and does exactly what I want.  I was hoping for a GUI method
but this works. 

Dale

:-)  :-) 

Wols Lists

unread,
Oct 8, 2022, 5:20:04 AM10/8/22
to
On 08/10/2022 04:44, Dale wrote:
> I might add, along with tab completion, I also use the highlight
> and middle click on the mouse.  A faster way to copy and paste when
> needed.  That's a nifty feature of Konsole.

I think that's been part of X since the dinosaurs were around. Try it
elsewhere, it works most places, afaik ...

Cheers,
Wol

Dale

unread,
Oct 8, 2022, 5:30:03 AM10/8/22
to
I think it is gpm or something that makes it work on a regular console
too.  It's been a long time since I installed it but I think that is the
name.  It is nifty tho.  I didn't know about it for a good while.  I
sort of found it by accident if I recall correctly. 

I'll keep a eye out for other places tho. 

Dale

:-)  :-) 

Frank Steinmetzger

unread,
Oct 8, 2022, 4:40:04 PM10/8/22
to
Am Thu, Oct 06, 2022 at 10:10:52AM +0200 schrieb Arve Barsnes:
> On Thu, 6 Oct 2022 at 06:40, Dale <rdale...@gmail.com> wrote:
> >
> > Howdy,
> >
> > This may not exist. If not, oh well. Sometimes when I'm moving files
> > with Dolphin, I need a added feature. I tend to use split panes when I
> > copy or move files. Quite often, I want to move files from one location
> > to another and the new file use the same name as the old file I'm
> > replacing. What I *wish* I could do, move the file from one pane to the
> > other and drag the new file on top of the old file and it replace it
> > with the name of the old file. As it is now, I have to bring up
> > properties, select the name of the file, while not including the
> > extension, and copy it, then close that window and open properties on
> > the new file, highlight the old name, paste new name, close window, copy
> > new file over and either delete old file or tell it to overwrite the
> > file. Sometimes it has a different extension and I have to delete
> > instead.

> This is probably a case of Dolphin not being a good tool, unless it
> has a built-in command-line?

It has: F4. And the path of that terminal is synced with that of the current
file view. That’s something you don’t get with Yakuake.

> 1. Equivalent to your method
> - Select old file, F2 (rename), ctrl+c, esc, select new file in other
> pane, shift+F6 (move with rename), ctrl+v, enter

Shift+F6 only moves without rename—only if the destination already
exists.

Dolphin has a „Copy address“ function: Ctrl+Alt+C. It will copy the absolute
path of a file to the clipboard. Then you can use tab completion in the
Dolphin terminal at the original file’s location and type:
mv <Beginning of source file><Tab>
and then insert the destination. This will at least save you from
completion-tabbing through the destination directory.

--
Grüße | Greetings | Qapla’
Please do not share anything from, with or about me on any social network.

“She understands. She doesn’t comprehend.” – River Tam, Firefly
signature.asc

Neil Bothwick

unread,
Oct 8, 2022, 5:00:03 PM10/8/22
to
On Fri, 7 Oct 2022 22:44:56 -0500, Dale wrote:

> I installed Yakuake and to me, it looks like Konsole but without the
> menu part at the top.  Other than that, I don't see anything special.  I
> kinda wish I had a terminal with dolphin or something.  I think there is
> a way but right now, I'm getting the job done.  I'll look into that
> later.  Pretty sure it is under the tool menu.

It is Konsole, but on demand. I have Konsole open on a separate desktop
permanently, but sometime I just want to run a quick shell command and
can press F12 to do it there and then.


--
Neil Bothwick

I@love~my,;It's%made in Taiwa~##$ ` #@

Neil Bothwick

unread,
Oct 8, 2022, 5:10:04 PM10/8/22
to
On Sat, 8 Oct 2022 03:18:30 -0500, Dale wrote:

> > Once Yakuake is running, F12 will open it in whichever virtual
> > desktop you happen to be and you can continue your work in the
> > terminal within that desktop. I'm not sure what other benefits it
> > has.
>
> I think since I always have Konsole open and ready, it is easier for me
> to use it.

The key point there is that it opens on the desktop you are using, so if
you need to refer to the program you are currently using, you have both
terminal and program together - that's where I find it useful.


--
Neil Bothwick

There are 10 types of people in this world, those who understand binary
notation and those who don't.

Dale

unread,
Oct 8, 2022, 6:20:03 PM10/8/22
to
Neil Bothwick wrote:
> On Sat, 8 Oct 2022 03:18:30 -0500, Dale wrote:
>
>>> Once Yakuake is running, F12 will open it in whichever virtual
>>> desktop you happen to be and you can continue your work in the
>>> terminal within that desktop. I'm not sure what other benefits it
>>> has.
>> I think since I always have Konsole open and ready, it is easier for me
>> to use it.
> The key point there is that it opens on the desktop you are using, so if
> you need to refer to the program you are currently using, you have both
> terminal and program together - that's where I find it useful.
>
>


I can see where that can be handy.  For me, once I start my video moves,
I just have to type on the first one then after that, I just highlight
and paste the parts that are the same and use tab completion for the
rest.  It goes pretty fast from there.  The other thing, because of how
I have Konsole set up, it wants to run as root instead of user.  I don't
want to change that so I sort of changed things that make it
incompatible for me so it is faster to just go to Konsole. 

Good idea for most tho.  I'm just a odd ball.  lol

Dale

:-)  :-) 

Mark Knecht

unread,
Oct 8, 2022, 6:30:04 PM10/8/22
to


On Sat, Oct 8, 2022 at 3:15 PM Dale <rdale...@gmail.com> wrote:
<SNIP>

> Good idea for most tho.  I'm just a odd ball.  lol
<SNIP>

Never truer words spoken... ;-)

Was following your thread because I'm working on a similar project here using Plex.

Cheers,
Mark

Arve Barsnes

unread,
Oct 9, 2022, 3:00:04 AM10/9/22
to
On Sat, 8 Oct 2022 at 22:33, Frank Steinmetzger <War...@gmx.de> wrote:
> Am Thu, Oct 06, 2022 at 10:10:52AM +0200 schrieb Arve Barsnes:
> > 1. Equivalent to your method
> > - Select old file, F2 (rename), ctrl+c, esc, select new file in other
> > pane, shift+F6 (move with rename), ctrl+v, enter
>
> Shift+F6 only moves without rename—only if the destination already
> exists.

Not sure what you mean here, although in essence any "rename"
operation in this context is always just a "mv" anyway. Maybe you
missed that I was talking about emelfm2, where shift+F6 lets you
change the name of the file you want to move before moving it. If you
change the name to something that exist in the destination, then
you'll get asked if you want to replace it.

Regards,
Arve

Neil Bothwick

unread,
Oct 9, 2022, 3:50:04 AM10/9/22
to
On Sat, 8 Oct 2022 17:15:28 -0500, Dale wrote:

> Good idea for most tho.  I'm just a odd ball.  lol

You'll get no argument from me ;-)


--
Neil Bothwick

Okay, who put a "stop payment" on my reality check?

Grant Edwards

unread,
Oct 9, 2022, 9:00:05 PM10/9/22
to
On 2022-10-08, Wols Lists <antl...@youngman.org.uk> wrote:
> On 08/10/2022 04:44, Dale wrote:
>> I might add, along with tab completion, I also use the highlight
>> and middle click on the mouse.  A faster way to copy and paste when
>> needed.  That's a nifty feature of Konsole.
>
> I think that's been part of X since the dinosaurs were around.

Indeed. X has worked that for the 35 years I've been using it.

> Try it elsewhere, it works most places, afaik ...

If there's anywhere that doesn't work, then something is broken.

--
Grant

Dale

unread,
Oct 23, 2022, 2:40:04 AM10/23/22
to
Dale wrote:
>
> This is a option I haven't thought of.  The mv command is a good
> thought.  Next time I have a lot of these to do, I'll try it.  It just
> may work.  Plus, tab completion would be a nice bonus.
>
> Thanks.
>
> Dale
>
> :-)  :-) 
>


Well, I ran into a slight problem.  This isn't much of a problem with
Linux but I'm not sure how this would work on windoze tho.  The problem,
if it is one, is the file extension.  Let's say I have a mp4 file that
is the older original file that I intend to replace.  If the file I
intend to put in its place is a .mkv file, mv uses the .mp4 extension
because all it cares about is the name of the file, not what it is or
its content.  So, I end up with a .mkv file that has a .mp4 extension. 
It works here on Linux but not sure about windoze and such.

I looked at the man page and I don't see a way to tell it to retain the
extension.  I see something about suffix but I don't think that is
related to this.  If I just backspace and change the extension, it
basically moves the file and I end up with both the old and new file.  I
wish I could write code and create a tool for this.  :/ 

Is there a way to work around this problem?  It works great except for
losing the file extension. 

Thanks.

Dale

:-)  :-) 

Frank Steinmetzger

unread,
Oct 23, 2022, 5:50:13 AM10/23/22
to
Am Sun, Oct 23, 2022 at 01:35:55AM -0500 schrieb Dale:

> Well, I ran into a slight problem.  This isn't much of a problem with
> Linux but I'm not sure how this would work on windoze tho.  The problem,
> if it is one, is the file extension.  Let's say I have a mp4 file that
> is the older original file that I intend to replace.  If the file I
> intend to put in its place is a .mkv file, mv uses the .mp4 extension
> because all it cares about is the name of the file, not what it is or
> its content.  So, I end up with a .mkv file that has a .mp4 extension. 
> It works here on Linux but not sure about windoze and such.

It’s not a problem for as long as the application you open the file with
does its own detection. I.e. you feed mp4 to mpv, but it recognises by
itself that it’s mp4 and can handle it.

> I looked at the man page and I don't see a way to tell it to retain the
> extension.  I see something about suffix but I don't think that is
> related to this.  If I just backspace and change the extension, it
> basically moves the file and I end up with both the old and new file.  I
> wish I could write code and create a tool for this.  :/ 
>
> Is there a way to work around this problem?  It works great except for
> losing the file extension. 

If you still want to stick to a terminal solution akin to mv, then there is
no way around a little script which wraps mv by extracting the extension and
filename base. You could also add some “intelligence” with regards to
directories, in order to reduce the amount of effort required to use the
command—in case your directories follow some schema or are constant.


#!/usr/bin/sh

[ "$#" -ne "2" ] && exit 1
SRC="$1"
DST="$2"

SRC_EXT="${SRC##*.}"
DST_BASE="${DST%.*}"

# remove destination for the case that the extensions differ
rm "$DST"

mv "$SRC" "${DST_BASE}${SRC_EXT}"

--
Grüße | Greetings | Salut | Qapla’
Please do not share anything from, with or about me on any social network.

“If you enjoy wasting time, is that time really wasted?” – Philosoraptor
signature.asc

Dale

unread,
Oct 23, 2022, 7:20:04 AM10/23/22
to
Frank Steinmetzger wrote:
> Am Sun, Oct 23, 2022 at 01:35:55AM -0500 schrieb Dale:
>
>> Well, I ran into a slight problem.  This isn't much of a problem with
>> Linux but I'm not sure how this would work on windoze tho.  The problem,
>> if it is one, is the file extension.  Let's say I have a mp4 file that
>> is the older original file that I intend to replace.  If the file I
>> intend to put in its place is a .mkv file, mv uses the .mp4 extension
>> because all it cares about is the name of the file, not what it is or
>> its content.  So, I end up with a .mkv file that has a .mp4 extension. 
>> It works here on Linux but not sure about windoze and such.
> It’s not a problem for as long as the application you open the file with
> does its own detection. I.e. you feed mp4 to mpv, but it recognises by
> itself that it’s mp4 and can handle it.

That is true on Linux.  Most linux software could care less what the
extension is or if it even has one.  Heck, you could likely change a
.mp4 to .txt and it would open with a video player just by clicking on
it.  Thing is, if I share a file with someone who uses windoze, I'm not
sure if it would work the same way.  A wrong extension could cause
problems, either not opening at all or crashing something.  It's
windoze, one can't expect much.  ROFL 

I thought about looking to see if there is a way to "scan" a directory
and look at each file and if needed, change the extension to the correct
one.  Thing is, I couldn't write a fancy script if my life depended on
it.  I also looked into using Krename to do it but it refuses to change
a extension.  Doing it one file at a time manually puts me back to where
it is easier to change the file the old way.  Time consuming but works. 


>> I looked at the man page and I don't see a way to tell it to retain the
>> extension.  I see something about suffix but I don't think that is
>> related to this.  If I just backspace and change the extension, it
>> basically moves the file and I end up with both the old and new file.  I
>> wish I could write code and create a tool for this.  :/ 
>>
>> Is there a way to work around this problem?  It works great except for
>> losing the file extension. 
> If you still want to stick to a terminal solution akin to mv, then there is
> no way around a little script which wraps mv by extracting the extension and
> filename base. You could also add some “intelligence” with regards to
> directories, in order to reduce the amount of effort required to use the
> command—in case your directories follow some schema or are constant.
>
>
> #!/usr/bin/sh
>
> [ "$#" -ne "2" ] && exit 1
> SRC="$1"
> DST="$2"
>
> SRC_EXT="${SRC##*.}"
> DST_BASE="${DST%.*}"
>
> # remove destination for the case that the extensions differ
> rm "$DST"
>
> mv "$SRC" "${DST_BASE}${SRC_EXT}"
>


Hmmmm.  I get a little of that but then I get lost.  Just how does that
work and how would I use it?  I think I would save that as a file, make
it executable and then run it with whatever name I give it.  I'm not
sure exactly how to tell it what files to move tho.  Same as mv maybe? 

Currently, I move to the main directory that files are in when I am in
Konsole and running as my user, so file permissions don't switch to
root.  My process on file organizing goes a little like this.  I have a
set of videos that go together.  When I have a new version of one or
more videos, I place them in a sub-directory until they are named
properly or something so I can move to the main directory.  Like this:

Main Directory  #Permanent location for files
----- Sub-directory  #Temporary location for files needing names changed
etc.  Once done, they move up to main directory.


A typical command for mv would be like this.

mv sub-directory/<file name of new file> <file name of old file in main
directory>

Just trying to follow this and figure out how to use it.  ;-)  I've said
this before, my scripting skills are so small it isn't funny.  :/

Dale

:-)  :-) 

Frank Steinmetzger

unread,
Oct 23, 2022, 8:00:04 AM10/23/22
to
Am Sun, Oct 23, 2022 at 06:16:04AM -0500 schrieb Dale:
> Frank Steinmetzger wrote:
> > Am Sun, Oct 23, 2022 at 01:35:55AM -0500 schrieb Dale:
> >
> >> Well, I ran into a slight problem.  This isn't much of a problem with
> >> Linux but I'm not sure how this would work on windoze tho.  The problem,
> >> if it is one, is the file extension.  Let's say I have a mp4 file that
> >> is the older original file that I intend to replace.  If the file I
> >> intend to put in its place is a .mkv file, mv uses the .mp4 extension
> >> because all it cares about is the name of the file, not what it is or
> >> its content.  So, I end up with a .mkv file that has a .mp4 extension. 
> >> It works here on Linux but not sure about windoze and such.
> > It’s not a problem for as long as the application you open the file with
> > does its own detection. I.e. you feed mp4 to mpv, but it recognises by
> > itself that it’s mp4 and can handle it.
>
> That is true on Linux.  Most linux software could care less what the
> extension is or if it even has one.

Mpv or Vlc on Windows will probably just work™, too.

> Heck, you could likely change a
> .mp4 to .txt and it would open with a video player just by clicking on
> it.  Thing is, if I share a file with someone who uses windoze, I'm not
> sure if it would work the same way.  A wrong extension could cause
> problems, either not opening at all or crashing something.  It's
> windoze, one can't expect much.  ROFL 

Now you’re talking about double-clicking in a file manager and open the
registered application. That’s the same—to some extent—on Linux file
managers. I was referring to an application that could work out the details.

> I thought about looking to see if there is a way to "scan" a directory
> and look at each file and if needed, change the extension to the correct
> one.  Thing is, I couldn't write a fancy script if my life depended on
> it.  I also looked into using Krename to do it but it refuses to change
> a extension.  Doing it one file at a time manually puts me back to where
> it is easier to change the file the old way.  Time consuming but works. 

Well, ther is the `file` tool, plus maybe `mediainfo` or `identify` for
images. But their output may not always be sufficient.

> > If you still want to stick to a terminal solution akin to mv, then there
> > is no way around a little script which wraps mv by extracting the
> > extension and filename base.

> Hmmmm.  I get a little of that but then I get lost.

The script first checks wheter it receives exactly two arguments, and exits
otherwise. In theory it should also check whether both paths exist and are
files. First rule of programming: always sanitise your inputs!

Now it gets the extension of the source file and the base part (i.e.
everything without the extension) from the destination. Then it deletes the
original destination file and finally moves the source by concatenating the
original destination’s base part with the source’s extension part.


>   Just how does that work and how would I use it?

I have a lot of little helper scripts. I collect them in ~/usr/bin, to which
my PATH is expanded in ~/.bashrc with export PATH=~/usr/bin:$PATH. Actually,
I keep the script files in git repositories under ~/dev, and then put
symlinks into ~/usr/bin, which point to the repository file.

> I think I would save that as a file, make it executable and then run it
> with whatever name I give it.

Exactly.

> I'm not sure exactly how to tell it what files to move tho.  Same as mv
> maybe? 

Yes. You give it two arguments. That’s what $1 and $2 are for in the script.
I always write my scripts so that they can handle spaces in filenames. I
find it an anachronism to still use underscores or dots in filenames where
spaces would go in normal language. File systems have been able to deal with
spaces for decades now.

> Currently, I move to the main directory that files are in when I am in
> Konsole and running as my user, so file permissions don't switch to root. 

That’s the proper way to do it. I also have a root console open all the
time, but don’t do normal file operations in there. The risk is too big that
I may be typing too fast for my own good.

> My process on file organizing goes a little like this.  I have a set of
> videos that go together.  When I have a new version of one or more videos,
> I place them in a sub-directory until they are named properly or something
> so I can move to the main directory.  Like this:
>
> Main Directory  #Permanent location for files ----- Sub-directory 
> #Temporary location for files needing names changed etc.  Once done, they
> move up to main directory.

I don’t quite understand the formatting of that line. But basically, you
have a directory for your videos, and in a subdiractory of that, you collect
your temporary files?

> A typical command for mv would be like this.
>
> mv sub-directory/<file name of new file> <file name of old file in main
> directory>

OK. That could actually be automated in a way. How many files per directory
are we talking about? Because one approach I can think of is a managament
script. It goes through all the files in your temp subdir, and for each file
it asks you which file to overwrite in the main directory. It then moves the
file, but keeps the extension as in my first script. But this isn’t
practical if there are dozens of files in the main dir, because you would
have to scroll through the big selection ist.

As an example, let’s assume we have the following file tree:

main
├── episode 1.mkv
├── episode 2.mpeg
├── episode 3.avi
└── temp
└── episode 2 with better quality.mkv

You cd into main, and start the script. It checks for the presence of the
temp dir and, if it exists, asks for each of its files what to do:

main$ VideoCleanupScript
Select file to overwrite with 'episode 2 with better quality.mkv':
1) episode 1.mkv
2) episode 2.mpeg
3) episode 3.avi
#? 2
Removing 'episode 2.mpeg'
Moving file 'episode 2 with better quality.mkv' -> 'episode 2.mkv'

> Just trying to follow this and figure out how to use it.  ;-)  I've said
> this before, my scripting skills are so small it isn't funny.  :/

I could write the above script in probably half an hour. Just say when. ;-)

I, too, have a few scripts that move files around. For example when I edit
photo albums, I do a final re-encoding of those images in different JPEG
quality levels as a trade-off between quality and storage space. For that I
have a script that asks me which level to keep whilst I look at the
different versions in a viewer. I then decide for one and the script picks
the appropriate file and moves it into the final folder. The other choices
are moved away so that if I halt the script midway, I can call it again and
pick up where I left it.

--
Grüße | Greetings | Salut | Qapla’
Please do not share anything from, with or about me on any social network.

Of all the people I’ve met you’re certainly one of them.
signature.asc

Grant Edwards

unread,
Oct 24, 2022, 10:00:04 AM10/24/22
to
On 2022-10-23, Dale <rdale...@gmail.com> wrote:

> That is true on Linux.  Most linux software could care less what the
> extension is or if it even has one.  Heck, you could likely change a
> .mp4 to .txt and it would open with a video player just by clicking on
> it.  Thing is, if I share a file with someone who uses windoze, I'm not
> sure if it would work the same way.  A wrong extension could cause
> problems, either not opening at all or crashing something.  It's
> windoze, one can't expect much.  ROFL 

A friend of mine once spent days trying to re-encode a video file into
a format that could be handled by a particular windows app. No matter
what codecs/parameters he tried, the app couldn't open the file. He
finally figured out that the app in question had hard requirements for
the filename suffix, and they chose a somewhat non-nstandard extension
for that container format.

It turned out that any of the codec/parameter combinations would have
been fine, it was just the filename that was causing the problem.

--
Grant

Peter Humphrey

unread,
Oct 24, 2022, 6:10:03 PM10/24/22
to
So the hubris of those two college dropouts still haunts the Windows world.
What a legacy.

--
Regards,
Peter.

Dale

unread,
Nov 22, 2022, 5:00:04 AM11/22/22
to
I finally got a chance to try this.  I saved it and made it executable. 
It runs but gave me this error. 


dmv torrent/video_name-old-place.mp4 video-name-new-place.mp4
bash: /bin/dmv: /usr/bin/sh: bad interpreter: No such file or directory
dale@fireball ~/Desktop/Crypt/Series $


My scripting skills are minimal at best.  Still, I kinda got what your
script was doing.  Those who have known me for a while understand how
miraculous that is.  ROFL  I did some googling.  It seems to not be able
to find the 'shebang' part.  Sure enough, sh isn't located in /usr/bin
here.  It's in /bin tho.  I edited that line so it can find it.  When I
tried it, it worked but noticed another problem.  It was leaving out the
dot, ".", before the extension.  Back into the script I went.  I revved
up my gears for a bit and made a edit.  When I tried it again, I was
shocked.  I almost fell in the floor.  Dang thing worked perfectly with
me only having to edit once.  I really did get how the script works,
sort of.  O_O 

This is the script as shown by cat:


root@fireball / # cat /bin/dmv
#!/bin/sh

[ "$#" -ne "2" ] && exit 1
SRC="$1"
DST="$2"

SRC_EXT="${SRC##*.}"
DST_BASE="${DST%.*}"

# remove destination for the case that the extensions differ
rm "$DST"

mv "$SRC" "${DST_BASE}.${SRC_EXT}"
root@fireball / #


I added a little . on that last line before the extension bit.  I'm a
happy camper.  Only thing is, turns out both source and destination file
have the same extension in this case.  Still, I bet it will work.  Then
I thought of a way to test this.  I just changed the extension on the
destination file and did a move.  I changed the .mp4 to .mkv on the
destination.  When I used your move script, it used the .mp4 extension
from the original source file but used the old name.  Perfect!!

Hope this makes the point.  THANK YOU MUCH!!!!

Dale

:-)  :-)

Frank Steinmetzger

unread,
Nov 22, 2022, 5:10:04 AM11/22/22
to
> tried it, it worked but noticed another problem. […]

Well, it would have been boring to provide you with a turn-key solution. ;-)
Congrats on getting it working. In my Arch setup, sh is in /usr/bin. A
flexible solution is to use #!/usr/bin/env sh, which looks the command up
before executing it.

> I added a little . on that last line before the extension bit.  I'm a
> happy camper.

Give me a nudge if you want the more luxurious version with interactive
selection of the overwrite destination. I think I already started a
prototype somewhere, but can’t find it right now.

--
Grüße | Greetings | Salut | Qapla’
Please do not share anything from, with or about me on any social network.

The best thing about Sundays is Saturday evening.
signature.asc

Dale

unread,
Nov 22, 2022, 7:20:03 AM11/22/22
to
Feel free to share.  Even if I don't use it, someone else may find it
and make good use of it.  It's one reason I posted the corrected version
and why I changed what I did.  Someone else just may run up on this and
find it helpful as well.  If possible and you have time, describe a bit
what each part does. 

Usually when I do this, I have several videos, anywhere from 10 to
sometimes 30 or more.  Sometimes I wish it could 'detect' which new one
goes with which old one.  Thing is, I don't know if a script can do this
or not.  Sometimes the new is named pretty different from the old.  I
don't think a script could do it reliably.  If things were more
consistent, maybe, but there is a lot of differences at times.  Your
scripts at least keeps the extension correct without adding any more
effort on my part, except having to type dmv instead of mv.  I chose d
since the first letter of my name is d.  It was something.  lol 

The current script sure is handy tho. 

Dale

:-)  :-) 

Wol

unread,
Nov 22, 2022, 2:20:04 PM11/22/22
to
On 22/11/2022 10:07, Frank Steinmetzger wrote:
>> My scripting skills are minimal at best.  Still, I kinda got what your
>> script was doing.  Those who have known me for a while understand how
>> miraculous that is.  ROFL  I did some googling.  It seems to not be able
>> to find the 'shebang' part.  Sure enough, sh isn't located in /usr/bin
>> here.  It's in /bin tho.  I edited that line so it can find it.  When I
>> tried it, it worked but noticed another problem. […]

> Well, it would have been boring to provide you with a turn-key solution. 😉
> Congrats on getting it working. In my Arch setup, sh is in /usr/bin. A
> flexible solution is to use #!/usr/bin/env sh, which looks the command up
> before executing it.
>
Everything should be in /usr/bin. /bin should be a symlink to /usr/bin I
believe.

People like to blame that on systemd, but actually I believe the
"change" predates systemd, and certainly has nothing whatsoever to do
with Lennart.

Most distros (especially systemd ones) are already there, Gentoo is
actively migrating in that direction.

And as someone who got bitten by that - writing a makefile (make
install) - on Gentoo and then having it blow up on SUSE, that day can't
come soon enough.

Cheers,
Wol

Wols Lists

unread,
Nov 22, 2022, 7:10:04 PM11/22/22
to
On 22/11/2022 21:58, Dale wrote:
> I'm top posting for those who want to ignore this message.
>
> This is the second message like this I've received.  Is anyone else
> getting these?  Did someone close their email account and not
> unsubscribe or something?  Is this just me?

No it's not just you. I'm getting them as well. My ISP is blaming
Microsoft but that doesn't seem to be the case with you.

I think there's been a global update of spam rules, and the big
providers seem to be having a spate of mis-classifying ham.

My wife sent an email to a friend (with an attachment) and it got caught
by MS's automated spam rules. No idea, no obvious spammy triggers ...
>
> Dale
>
Cheers,
Wol
>
> postm...@outlook.com wrote:
>>
>> *Delivery has failed to these recipients or groups:*
>>
>> yna...@gmail.com <mailto:yna...@gmail.com>
>> Your message wasn't delivered because the recipient's email provider
>> rejected it.
>>
>>

Frank Steinmetzger

unread,
Nov 23, 2022, 6:40:04 AM11/23/22
to
Am Tue, Nov 22, 2022 at 06:17:09AM -0600 schrieb Dale:
> Frank Steinmetzger wrote:

> >> I added a little . on that last line before the extension bit.  I'm a
> >> happy camper.
> > Give me a nudge if you want the more luxurious version with interactive
> > selection of the overwrite destination. I think I already started a
> > prototype somewhere, but can’t find it right now.
> >
>
> Feel free to share.  Even if I don't use it, someone else may find it
> and make good use of it.


There ya goo. As I suspected, I already wrote most of it in October right
away, I only couldn’t find the file until now. I just had to fix the same
bugs as in the first script (and some more in the additional parts :D ),
and put some more grease into the interal logic and output strings.

--
Grüße | Greetings | Salut | Qapla’
Please do not share anything from, with or about me on any social network.

“To some degree people say you should not micro-optimise.
But if what you love is micro-optimisation, that’s what you should do.”
– Linus Torvalds
Mv
signature.asc

Dale

unread,
Nov 23, 2022, 7:00:04 AM11/23/22