public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download: 
* Re: [gentoo-user] Dolphin and adding a option, if it exists.
  @ 2022-10-23 11:57 99%             ` Frank Steinmetzger
  0 siblings, 0 replies; 1+ results
From: Frank Steinmetzger @ 2022-10-23 11:57 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 7219 bytes --]

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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[relevance 99%]

Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2022-10-06  4:39     [gentoo-user] Dolphin and adding a option, if it exists Dale
2022-10-06  8:10     ` Arve Barsnes
2022-10-06 12:45       ` Neil Bothwick
2022-10-06 17:41         ` Dale
2022-10-23  6:35           ` Dale
2022-10-23  9:41             ` Frank Steinmetzger
2022-10-23 11:16               ` Dale
2022-10-23 11:57 99%             ` Frank Steinmetzger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox