How to use Puppy's rename command? [Solved]

interpretive language scripts


Moderator: Forum moderators

Post Reply
User avatar
Jasper
Posts: 1589
Joined: Wed Sep 07, 2022 1:20 pm
Has thanked: 674 times
Been thanked: 357 times

How to use Puppy's rename command? [Solved]

Post by Jasper »

Strange ............ this is the second time I am posting this message.

I have a large number of podcasts that I wish to rename to remove the following characters

[content]

Image

I did try to do this, but the script fails to make the required changes

Image

Some advice/tips/suggestions would be welcome.

Thanks in advance!

Last edited by Jasper on Mon May 08, 2023 7:39 am, edited 2 times in total.
Burunduk
Posts: 244
Joined: Thu Jun 16, 2022 6:16 pm
Has thanked: 6 times
Been thanked: 122 times

Re: Help using the rename command

Post by Burunduk »

The rename command in puppy is different from what you probably expect. The syntax in your script is for the perl rename command. In the PPM of Fossapup64, the deb package is called rename_1.10 (the command it installs is prename or file-rename).

User avatar
Jasper
Posts: 1589
Joined: Wed Sep 07, 2022 1:20 pm
Has thanked: 674 times
Been thanked: 357 times

Re: Help using the rename command

Post by Jasper »

@Burunduk

Thank you for your reply and solution.

Sh...................... I just updated "rename" and some other common utilities from here:

https://github.com/util-linux/util-linux

I will grab the application from the PPM :thumbup2:

*UPDATE*

I did install from the PPM, but still unsuccessful :cry:

Burunduk
Posts: 244
Joined: Thu Jun 16, 2022 6:16 pm
Has thanked: 6 times
Been thanked: 122 times

Re: Help using the rename command

Post by Burunduk »

Yes, the puppy's rename is from util-linux. I don't think it can use a regex, it can only replace a fixed substring in file names.

I've tested the prename (file-rename) here and it works, file-rename 's/\[.*\]//' *.txt removes the [...] part from the file names (if this is what you need). Maybe you have too many files to rename and the command is too long. find . -name '*.txt' -exec file-rename 's/\[.*\]//' {} + may work then. Have you got an error message of some kind?

By the way, one of the go commands I've mentioned before is f2 (viewtopic.php?t=4309) It's now at 1.9.0: https://github.com/ayoisaiah/f2/releases. The command would be f2 -f '\[.*\]' (dry-run) or f2 -xf '\[.*\]' (rename).

User avatar
MochiMoppel
Posts: 1115
Joined: Mon Jun 15, 2020 6:25 am
Location: Japan
Has thanked: 17 times
Been thanked: 359 times

Re: Help using the rename command

Post by MochiMoppel »

In principle ROX-Filer's bulk rename tool can do the job. Not ideal though when the files reside in numerous subdirectories because then the job has to be repeated for each subdirectory.

Screenshot.png
Screenshot.png (24.07 KiB) Viewed 856 times
User avatar
Jasper
Posts: 1589
Joined: Wed Sep 07, 2022 1:20 pm
Has thanked: 674 times
Been thanked: 357 times

Re: Help using the rename command

Post by Jasper »

@Burunduk

Your example

file-rename 's/\[.*\]//' *.txt (changed to m4a)

worked perfectly :thumbup: I did have to load up Perl via the DevX just to run the command.

I will try out your suggestion of the f2 binary as well :thumbup: That would be a more convenient option.

I do listen to a lot of podcasts especially when travelling/exercising so having them display correctly is a personal preference. So many thanks to you as always :thumbup2:

User avatar
Jasper
Posts: 1589
Joined: Wed Sep 07, 2022 1:20 pm
Has thanked: 674 times
Been thanked: 357 times

Re: Help using the rename command

Post by Jasper »

@MochiMoppel

Thanks also for sharing your tip.

I did try it, but it did not proceed with any changes :(

Image

User avatar
MochiMoppel
Posts: 1115
Joined: Mon Jun 15, 2020 6:25 am
Location: Japan
Has thanked: 17 times
Been thanked: 359 times

Re: Help using the rename command [SOLVED]

Post by MochiMoppel »

Push the "Apply" button. This will display a preview. When satisfied with result, push "Rename"

User avatar
Jasper
Posts: 1589
Joined: Wed Sep 07, 2022 1:20 pm
Has thanked: 674 times
Been thanked: 357 times

Re: Help using the rename command [SOLVED]

Post by Jasper »

@MochiMoppel

How embarrassing for me :oops: I didn't click on the apply button before

It also works perfectly too, many many thanks :thumbup:

Image

User avatar
Jasper
Posts: 1589
Joined: Wed Sep 07, 2022 1:20 pm
Has thanked: 674 times
Been thanked: 357 times

Re: How to use Puppy's rename command? (Solved by ROX)

Post by Jasper »

@Burunduk

The latest build v1.90 of f2 requires a newer build of GLibC (2.34), so I grabbed v1.80 which is perfectly fine for Fossapup64-95 :thumbup:

It is pretty cool in it's abilities and has so many practical applications for me lol ........ finally can catalogue my music collection correctly :lol:

Image

Burunduk
Posts: 244
Joined: Thu Jun 16, 2022 6:16 pm
Has thanked: 6 times
Been thanked: 122 times

Re: How to use Puppy's rename command? [Solved]

Post by Burunduk »

Jasper wrote: Mon May 08, 2023 7:38 am

The latest build v1.90 of f2 requires a newer build of GLibC (2.34)

On Android. f2_1.9.0_linux_amd64.deb is static and works on Fossapup64-9.5. But 1.8.0 is OK too. The "capture variables with indexing" in 1.9.0 are important only if you need indexing.

User avatar
MochiMoppel
Posts: 1115
Joined: Mon Jun 15, 2020 6:25 am
Location: Japan
Has thanked: 17 times
Been thanked: 359 times

Re: How to use Puppy's rename command? [Solved]

Post by MochiMoppel »

@Jasper Since the thread title still refers to "Puppy's rename command" let's see how far we can get with Puppy's rename
Here is a script that is as close as possible to your rename_files.sh script. Does not require regex.

Code: Select all

#!/bin/sh
for file in *.m4a ; do
    head=${file#*[}     #part of file name up to (and including) left bracket '['
    find=[${head%]*}]   #pair of brackets with string (=the stuff that should be removed)
    rename  "$find" '' "$file"
done
User avatar
Jasper
Posts: 1589
Joined: Wed Sep 07, 2022 1:20 pm
Has thanked: 674 times
Been thanked: 357 times

Re: How to use Puppy's rename command? [Solved]

Post by Jasper »

@Burunduk

Thanks again, I downloaded the "Android" binary in error. Which spat out the error message.

@MochiMoppel Thanks once again!!

Your Rox suggestion is suitable for individual directorys as you mentioned.

I did successfully rename all my files earlier today. As most of my subscriptions are weekly, I have to wait for more content.

I will download some previous episodes once again to check the script.

User avatar
MochiMoppel
Posts: 1115
Joined: Mon Jun 15, 2020 6:25 am
Location: Japan
Has thanked: 17 times
Been thanked: 359 times

Re: How to use Puppy's rename command? [Solved]

Post by MochiMoppel »

Jasper wrote: Mon May 08, 2023 4:28 pm

I did successfully rename all my files earlier today. As most of my subscriptions are weekly, I have to wait for more content.
I will download some previous episodes once again to check the script.

IMO you don't need to download anything and you should never test a script with your precious original files.
Just make a test folder with copies of your files and manually rename them to their original name for testing.

The rename command has the ability to create a preview, just like ROX-Filer's bulk rename, Of course would make the script more complex and may not be needed if you are certain that the script does what you want it to do. However please note that all solutions proposed so far will have unpredictable results if file names contain more that one pair of brackets. Would need a slightly different test pattern to make the scripts rock solid (in ROX-Filer you could use the Replace pattern \[[^]]*\] and then push the "Apply" button - in case of multiple brackets more than once, until all brackets are removed)

User avatar
Jasper
Posts: 1589
Joined: Wed Sep 07, 2022 1:20 pm
Has thanked: 674 times
Been thanked: 357 times

Re: How to use Puppy's rename command? [Solved]

Post by Jasper »

@MochiMoppel

Thank you for your concern........... sometimes I lack some common sense :lol:

The podcasts are incredibly low quality 64kbps or thereabouts but more than enough to be heard back on the phone/speakers. Both of these have EQ's that make them sound better. Also, for this directory, they are deleted once I have heard them. I only retain the most interesting ones and those that have a repeat value.

I can confirm that your script works, thanks again :thumbup:

Post Reply

Return to “Scripts”