New recursive batch filename converter

Filemanagers, partitioning tools, etc.
Post Reply
Message
Author
User avatar
ravensrest
Posts: 365
Joined: Fri 22 Feb 2008, 16:43
Location: Grants Pass, Oregon

New recursive batch filename converter

#1 Post by ravensrest »

Renamcon (REcursive NAMe CONverter) is a bash script implementing an Xdialog-based gui for the sed editor. The file renamers that come with Puppy are fine programs, but they do not operate recursively. To manipulate my music and photo files, I needed a program that would deal with thousands of files in hundreds of directories, some of them nested several layers deep. This script does so. It is not designed to replace PRename or gFnRename, but to complement them. It is only a single file, so I did not build a pet for it. Download the attached file, expand it, put it in a directory of your choice (/usr/sbin works well), give yourself permission to execute it, and start by double clicking its name. Alternately, drag it to the desk top, assign it an icon, and start it from there.

Renamcon automates a number of common filename conversions and replacements. It will rename either files or directories, and defaults to recurse through 50 layers of directories, but can be reset to recurse through any number. It processes requests sequentially. First, you select the starting directory and choose whether to accept the default recursion depth or change it -- not much need to change unless you want to limit your search to the current directory (depth = 1) or only a layer or two beneath it, or have directories stacked more than 50 deep. Then you decide whether to process directories, files, or particular files. If you select particular files, you enter the character pattern for the names you want to process (like "*.ogg" to find your music files). Then you jump to the main menu where you can select from a list of possible actions. You can execute multiple actions one after the other, or restart in order to select other files or directories. Read the mini-help file there for additional information.

The linux find command is used to locate the files to be processed. It is very fast. It lists all 59,000 files in my computer (2.53 GHz Celeron running Wary 5.0) in about 3-4 seconds . However, the items in the main menu examine each file matching your search criteria on a line-by-line basis. This is much slower. It takes about 40 seconds for my computer to list changes to 2500 files, and 35 seconds to implement those changes. So if you need to search for a particular pattern to replace, do it when you are asked for particular files, and not from the main menu.

After the potential changes have all been found, they are presented to you for confirmation in an Xdialog editbox. This widget lets you edit its contents, so you can make additional changes there if you want to. I don't recommend it. One of the nice features of doing everything sequentially is that if you make a mistake in any step, it is relatively easy to recover from it. Making arbitrary and random changes can only be corrected manually, if you can locate them again. And do not change the path names in the confirmation box because if you change a path name the program may not be able to find any files pointed to by the old path name.

I also recommend that if you are processing large numbers of files, or having trouble with renamcon, that you run it in a terminal. It will print its intermediate steps to the terminal so you can see what it is doing.

You can also use Renamcon as a simple file finder. Enter the starting directory, and choose particular files. Enter the appropriate search pattern, and from the main menu, select List only. It will locate and display all files matching your pattern.

In addition, Renamcon counts all the files matching your criteria giving you a quick reckoning of how many of what are in your computer.

This is its first release, so let me know if you encounter any problems. Feel free to modify the script for your own use, but if you pass it on, please comment any changes you have made.

Edit: In response to Flash's request, if you select 'Directories' and then 'List only' from the main menu, the directory listing will appear in treeview format with each subdirectory indented by 3 hyphens from the next higher level. Updated file attached.
Attachments
renamcon.gz
(4.72 KiB) Downloaded 983 times
Last edited by ravensrest on Fri 18 Feb 2011, 22:28, edited 2 times in total.

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#2 Post by Flash »

Pretty good, ravensrest. Tree will show the subfolders contained within a folder, without showing the files in those subfolders. Would it be very difficult to include that feature?

User avatar
ravensrest
Posts: 365
Joined: Fri 22 Feb 2008, 16:43
Location: Grants Pass, Oregon

#3 Post by ravensrest »

Flash, renamcon will simply list the directories if you select directories instead of files. However, it is a simple list, not the diagramatic view that the Xdialog treeview widget yields. If that is what you need, pm me and I'll see if I can incorporate it.
BS

User avatar
abushcrafter
Posts: 1418
Joined: Fri 30 Oct 2009, 16:57
Location: England
Contact:

#4 Post by abushcrafter »

Thanks muchly. I am replacing PRename and gfnrename with this :D. Yes I know you said
It is not designed to replace PRename or gFnRename.
.
[url=http://www.adobe.com/flashplatform/]adobe flash is rubbish![/url]
My Quote:"Humans are stupid, though some are clever but stupid." http://www.dependent.de/media/audio/mp3/System_Syn_Heres_to_You.zip http://www.systemsyn.com/

User avatar
ravensrest
Posts: 365
Joined: Fri 22 Feb 2008, 16:43
Location: Grants Pass, Oregon

#5 Post by ravensrest »

Updated renamcon to satisfy Flash's request. File attached to original posting.
BS

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#6 Post by Flash »

Wow, thanks! I only meant to find out how much trouble it would be to include the feature. I hope it wasn't very much trouble. Now I suppose I have to test it. :lol: That shouldn't take long at all.

No file management program I'm aware of in Linux or Windows offers the option of showing all the sub-directories in a directory in tree form, like Tree does. So, every time someone creates a new program that looks like it might naturally include that capability, I ask how hard it would be to include it. What I'm really asking is, is that capability a natural component of the program, but it was left out of the original specification of the program? Does that make sense?

Later: Okay, I tried it and found that it does what I want and is very easy to use. I have a large number of audio books I've converted to mp3 so I can put more of them on my mp3 player, to listen to while I work. The problem is, when I want to put more of them on the mp3 player, I have to open each author to see what the book is, before I decide if I want to listen to it. Being able to see all the authors and books in a single tree view makes it much faster to decide which ones to put on the mp3 player. Thanks again!
------Mp3_books
---------Barry, Brunonia
------------The Lace Reader
---------Brown, Dee
------------Bury My Heart At Wounded Knee
---------Buffett, Jimmy
------------A Salty Piece of Land
---------Carlson, Ron
------------The Signal
---------Chiaverini, Jennifer
------------The Aloha Quilt
------------The Lost Quilter
------------The Quilter's Legacy
---------Eggers, Dave
------------The Wild Things
---------Evans, Mary Anna
------------Findings
---------Fuller, Alexandra
------------Scribbling the Cat
---------Gladwell, Malcolm
------------What the Dog Saw
---------Hoffman, Alice
------------Turtle Moon
---------Hornby, Nick
------------Fever Pitch
---------Lehane, Dennis
------------Moonlight Mile
---------Lescroart, John
------------Nothing but the Truth
---------------01
---------------02
---------------03
---------------04
---------------05
---------------06
---------------07
---------------08
---------------09
---------------10
---------------11
---------------12
---------------13
---------------14
---------Lippman, Laura
------------I'd Know You Anywhere
---------Margolin, Phillip
------------Fugitive
---------Maron, Margaret
------------Death's Half Acre
------------Hard Row
---------Mortenson, Greg
------------Stones into Schools - Afghanistan
---------Patchett, Ann
------------Bel Canto
---------Paton, Alan
------------Cry, The Beloved Country
---------Patterson, James
------------Alex Cross's Trial
---------Patterson, James and Dilallo, Richard
------------Alex Cross's Trial
---------Rakove, Jack
------------Revolutionaries - the beginning of the U.S
---------Schlink, Bernhard
------------The Weekend
---------Webb,_Betty
------------Desert Cut
------------The Anteater of Death
------------The Koala of Death
---------White, Randy Wayne
------------Black Widow
---------Woods, Stuart
------------Fresh Disasters

User avatar
sc0ttman
Posts: 2812
Joined: Wed 16 Sep 2009, 05:44
Location: UK

#7 Post by sc0ttman »

It looks nice, but I think you need 2 simple changes to the GUI:

1. the height of the selection window should be fixed, so we don't get those long GUIs which take up most of the screen, if not more than! (netbooks, low resolutions)..

2. I am confused about replacing a string. I don't know what to enter - backslash, as it said, or forward slash, as they example shows. (I attached a screenshot)
Attachments
renamcon.jpg
(12.9 KiB) Downloaded 3237 times
[b][url=https://bit.ly/2KjtxoD]Pkg[/url], [url=https://bit.ly/2U6dzxV]mdsh[/url], [url=https://bit.ly/2G49OE8]Woofy[/url], [url=http://goo.gl/bzBU1]Akita[/url], [url=http://goo.gl/SO5ug]VLC-GTK[/url], [url=https://tiny.cc/c2hnfz]Search[/url][/b]

User avatar
ravensrest
Posts: 365
Joined: Fri 22 Feb 2008, 16:43
Location: Grants Pass, Oregon

#8 Post by ravensrest »

Flash, glad you like it. The only changes necessary were basically the IF statement lines, 313-317. If you want some other character than --- to precede the listings, open the script and substitute the character of your choosing in line 314 in place of the --- that is already there.

sc0ttman, input the string to replace, a slash as shown, and the string to use in place of the old one. If in doubt about anything, simply try it; renamcon always presents the proposed changes first, and will not commit to them unless you answer OK.

I am a bit in doubt about designing custom software for each user's needs. This script is very easy to modify, and pretty well documented internally. If you want fixed length/width dialog boxes, open the script in Geany, search for 0 0 (zero-space-zero), and replace the zeros with the length and width you like.

User avatar
abushcrafter
Posts: 1418
Joined: Fri 30 Oct 2009, 16:57
Location: England
Contact:

#9 Post by abushcrafter »

Hello. I would like to use this on my nano note. The NN OS is quite like Puppy. I have replaced xdialog with "dialog" because I have no X one my NN and no xdialog in ubuntu. Trying to run it on ubuntu but I get "Unexpected error with change_dir."

Your help/time/work/assistance will be appreciated.
[url=http://www.adobe.com/flashplatform/]adobe flash is rubbish![/url]
My Quote:"Humans are stupid, though some are clever but stupid." http://www.dependent.de/media/audio/mp3/System_Syn_Heres_to_You.zip http://www.systemsyn.com/

Post Reply