Gentoo Archives: gentoo-user

From: Dale <rdalek1967@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Dolphin and adding a option, if it exists.
Date: Sun, 23 Oct 2022 11:16:13
In Reply to: Re: [gentoo-user] Dolphin and adding a option, if it exists. by Frank Steinmetzger
1 Frank Steinmetzger wrote:
2 > Am Sun, Oct 23, 2022 at 01:35:55AM -0500 schrieb Dale:
3 >
4 >> Well, I ran into a slight problem.  This isn't much of a problem with
5 >> Linux but I'm not sure how this would work on windoze tho.  The problem,
6 >> if it is one, is the file extension.  Let's say I have a mp4 file that
7 >> is the older original file that I intend to replace.  If the file I
8 >> intend to put in its place is a .mkv file, mv uses the .mp4 extension
9 >> because all it cares about is the name of the file, not what it is or
10 >> its content.  So, I end up with a .mkv file that has a .mp4 extension. 
11 >> It works here on Linux but not sure about windoze and such.
12 > It’s not a problem for as long as the application you open the file with
13 > does its own detection. I.e. you feed mp4 to mpv, but it recognises by
14 > itself that it’s mp4 and can handle it.
16 That is true on Linux.  Most linux software could care less what the
17 extension is or if it even has one.  Heck, you could likely change a
18 .mp4 to .txt and it would open with a video player just by clicking on
19 it.  Thing is, if I share a file with someone who uses windoze, I'm not
20 sure if it would work the same way.  A wrong extension could cause
21 problems, either not opening at all or crashing something.  It's
22 windoze, one can't expect much.  ROFL 
24 I thought about looking to see if there is a way to "scan" a directory
25 and look at each file and if needed, change the extension to the correct
26 one.  Thing is, I couldn't write a fancy script if my life depended on
27 it.  I also looked into using Krename to do it but it refuses to change
28 a extension.  Doing it one file at a time manually puts me back to where
29 it is easier to change the file the old way.  Time consuming but works. 
32 >> I looked at the man page and I don't see a way to tell it to retain the
33 >> extension.  I see something about suffix but I don't think that is
34 >> related to this.  If I just backspace and change the extension, it
35 >> basically moves the file and I end up with both the old and new file.  I
36 >> wish I could write code and create a tool for this.  :/ 
37 >>
38 >> Is there a way to work around this problem?  It works great except for
39 >> losing the file extension. 
40 > If you still want to stick to a terminal solution akin to mv, then there is
41 > no way around a little script which wraps mv by extracting the extension and
42 > filename base. You could also add some “intelligence” with regards to
43 > directories, in order to reduce the amount of effort required to use the
44 > command—in case your directories follow some schema or are constant.
45 >
46 >
47 > #!/usr/bin/sh
48 >
49 > [ "$#" -ne "2" ] && exit 1
50 > SRC="$1"
51 > DST="$2"
52 >
53 > SRC_EXT="${SRC##*.}"
54 > DST_BASE="${DST%.*}"
55 >
56 > # remove destination for the case that the extensions differ
57 > rm "$DST"
58 >
59 > mv "$SRC" "${DST_BASE}${SRC_EXT}"
60 >
63 Hmmmm.  I get a little of that but then I get lost.  Just how does that
64 work and how would I use it?  I think I would save that as a file, make
65 it executable and then run it with whatever name I give it.  I'm not
66 sure exactly how to tell it what files to move tho.  Same as mv maybe? 
68 Currently, I move to the main directory that files are in when I am in
69 Konsole and running as my user, so file permissions don't switch to
70 root.  My process on file organizing goes a little like this.  I have a
71 set of videos that go together.  When I have a new version of one or
72 more videos, I place them in a sub-directory until they are named
73 properly or something so I can move to the main directory.  Like this:
75 Main Directory  #Permanent location for files
76 ----- Sub-directory  #Temporary location for files needing names changed
77 etc.  Once done, they move up to main directory.
80 A typical command for mv would be like this.
82 mv sub-directory/<file name of new file> <file name of old file in main
83 directory>
85 Just trying to follow this and figure out how to use it.  ;-)  I've said
86 this before, my scripting skills are so small it isn't funny.  :/
88 Dale
90 :-)  :-) 


Subject Author
Re: [gentoo-user] Dolphin and adding a option, if it exists. Frank Steinmetzger <Warp_7@×××.de>
[gentoo-user] Re: Dolphin and adding a option, if it exists. Grant Edwards <grant.b.edwards@×××××.com>