rename instead of rename (perl instead of unix-util)


cen

Recommended Posts

 

Hi there,

 

over the years I have been using the bash  rename  for renaming the music (mp3 and/or flac) I buy (which of course never comes named as I prefer). I would also like to use this on unraid when I log in via SSH or when I use the link to the (web)Terminal but it doesn't work as expected (due to the fact that there are at least 3 different rename's out there).

 

I guess upto now I never had the problem of a non working rename command as I would always automatically install the perl version of rename with the regex renaming I am used to. On unraid it uses rename from unix-util.

 

Is there any non-system-corrupting option (in case other programs use the unix-util rename) of using the perl rename in unraid?

Thank you.

 

 

 

Link to comment
  • 3 weeks later...
  • 1 year later...

 I received a question asking how I "installed" the linux rename program for batch renaming on Unraid and I would like to post my answer here in case someone else might also be looking for an option like this.  

   

If you are a novice in unraid and linux maybe a plugin would be better. You should be able to find something like a rename program or such with a gui over vnc to suit your needs. The Krusader Plugin is one I know of (but I'm not sure if it has a renaming option... but if not then you should be able to add this functionality to Krusader) and I've used it in the past (not in a long time anymore). 

  

rename is a linux program which is included in serveral distributions from begin but not in Unraid. It is the program I have gotten used to because it is very powerful in renaming a whole bunch of files at once. I use it almost daily and know only one program which is a bit better and has a nice GUI in the windows ecosystem (called "bulk rename utility").

 

rename is a CLI program which is used in the terminal. This is good for Unraid because access to files via ssh over a command line is the easiest and fastest way to organise your files. rename is very powerful because you can use regex (regular expressions) for renaming files. But using terminal takes getting used to and you should be careful with the terminal over ssh since you can also easily remove and delete or overwrite your files if you're not sure what you're doing (and even if you think you know what you're doing;).  

  

There are several sites with tutorials on rename for getting started but the option for rename you should use the most is rename -n (which only does a dry run without actually renaming the files but showing the output of the command).   

 

"Installation":

Since rename is not available in Unraid I found a version on github which I could "install". The program is downloaded via wget from here: https://gist.github.com/javiermon/3939556 . 

wget https://gist.githubusercontent.com/javiermon/3939556/raw/b9d0634f2c099b825a483d3d75cae1712fb9aa31/prename.pl

Then I copied the prename.pl to the /usr/bin/ folder. This is the linux folder for binary files / programs which can be started in the command line without stating where the program is to be found (like /user/bin/prename.pl xyz...) so you can just start it by typing pren + TAB (which should return prename.pl since TAB is autocompletion). After that I could use rename aka prename.pl in the command line via ssh. 

For example one of the things I use often is the following for getting rid of whitespaces in filenamens: 

prename.pl 's/\ /./g' ./*

And some more options can be seen here when renaming music files I bought and which I get from the producer as a zip download containing the music files in the original (not my;) naming-sheme: 

prename.pl 's/(.*) - Spear.*2020 - (\d\d)\ (.*)/SPEAR104_$2_$1_\L$3/' *.flac

 Hope that helps a bit. 

 

 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.