Page 1 of 1
How to use Puppy's rename command? [Solved]
Posted: Sun May 07, 2023 8:05 pm
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]
I did try to do this, but the script fails to make the required changes
Some advice/tips/suggestions would be welcome.
Thanks in advance!
Re: Help using the rename command
Posted: Sun May 07, 2023 9:30 pm
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).
Re: Help using the rename command
Posted: Sun May 07, 2023 9:45 pm
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
*UPDATE*
I did install from the PPM, but still unsuccessful
Re: Help using the rename command
Posted: Sun May 07, 2023 10:49 pm
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).
Re: Help using the rename command
Posted: Sun May 07, 2023 11:41 pm
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 (24.07 KiB) Viewed 1913 times
Re: Help using the rename command
Posted: Sun May 07, 2023 11:51 pm
by Jasper
@Burunduk
Your example
file-rename 's/\[.*\]//' *.txt (changed to m4a)
worked perfectly 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 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
Re: Help using the rename command
Posted: Sun May 07, 2023 11:58 pm
by Jasper
@MochiMoppel
Thanks also for sharing your tip.
I did try it, but it did not proceed with any changes
Re: Help using the rename command [SOLVED]
Posted: Mon May 08, 2023 12:01 am
by MochiMoppel
Push the "Apply" button. This will display a preview. When satisfied with result, push "Rename"
Re: Help using the rename command [SOLVED]
Posted: Mon May 08, 2023 12:08 am
by Jasper
@MochiMoppel
How embarrassing for me I didn't click on the apply button before
It also works perfectly too, many many thanks
Re: How to use Puppy's rename command? (Solved by ROX)
Posted: Mon May 08, 2023 7:38 am
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
It is pretty cool in it's abilities and has so many practical applications for me lol ........ finally can catalogue my music collection correctly
Re: How to use Puppy's rename command? [Solved]
Posted: Mon May 08, 2023 9:12 am
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.
Re: How to use Puppy's rename command? [Solved]
Posted: Mon May 08, 2023 3:07 pm
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
Re: How to use Puppy's rename command? [Solved]
Posted: Mon May 08, 2023 4:28 pm
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.
Re: How to use Puppy's rename command? [Solved]
Posted: Tue May 09, 2023 1:49 am
by MochiMoppel
Jasper wrote: Mon May 08, 2023 4:28 pmI 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)
Re: How to use Puppy's rename command? [Solved]
Posted: Tue May 09, 2023 6:27 am
by Jasper
@MochiMoppel
Thank you for your concern........... sometimes I lack some common sense
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