Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Fri 28 Nov 2014, 04:51
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Filesystem
New recursive batch filename converter
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [9 Posts]  
Author Message
ravensrest


Joined: 22 Feb 2008
Posts: 321
Location: Hood Canal, WA

PostPosted: Thu 17 Feb 2011, 18:59    Post subject:  New recursive batch filename converter
Subject description: batch filename recursive file name path pathname directory
 

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.
renamcon.gz
Description 
gz

 Download 
Filename  renamcon.gz 
Filesize  4.72 KB 
Downloaded  659 Time(s) 

Last edited by ravensrest on Fri 18 Feb 2011, 18:28; edited 2 times in total
Back to top
View user's profile Send private message 
Flash
Official Dog Handler


Joined: 04 May 2005
Posts: 11164
Location: Arizona USA

PostPosted: Thu 17 Feb 2011, 23:37    Post subject:  

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?
Back to top
View user's profile Send private message 
ravensrest


Joined: 22 Feb 2008
Posts: 321
Location: Hood Canal, WA

PostPosted: Fri 18 Feb 2011, 12:18    Post subject:  

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
Back to top
View user's profile Send private message 
abushcrafter


Joined: 30 Oct 2009
Posts: 1447
Location: England

PostPosted: Fri 18 Feb 2011, 15:10    Post subject:  

Thanks muchly. I am replacing PRename and gfnrename with this Very Happy. Yes I know you said
Quote:
It is not designed to replace PRename or gFnRename.
.
_________________
adobe flash is rubbish!
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/
Back to top
View user's profile Send private message Visit poster's website 
ravensrest


Joined: 22 Feb 2008
Posts: 321
Location: Hood Canal, WA

PostPosted: Fri 18 Feb 2011, 18:30    Post subject:  

Updated renamcon to satisfy Flash's request. File attached to original posting.
BS
Back to top
View user's profile Send private message 
Flash
Official Dog Handler


Joined: 04 May 2005
Posts: 11164
Location: Arizona USA

PostPosted: Fri 18 Feb 2011, 23:13    Post subject:  

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. Laughing 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!

Quote:
------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
Back to top
View user's profile Send private message 
sc0ttman


Joined: 16 Sep 2009
Posts: 2386
Location: UK

PostPosted: Sat 19 Feb 2011, 09:17    Post subject:  

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)
renamcon.jpg
 Description   
 Filesize   12.9 KB
 Viewed   2662 Time(s)

renamcon.jpg


_________________
Akita Linux, VLC-GTK, Pup Search, Pup File Search
Back to top
View user's profile Send private message 
ravensrest


Joined: 22 Feb 2008
Posts: 321
Location: Hood Canal, WA

PostPosted: Sat 19 Feb 2011, 11:46    Post subject:  

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.
Back to top
View user's profile Send private message 
abushcrafter


Joined: 30 Oct 2009
Posts: 1447
Location: England

PostPosted: Sun 14 Oct 2012, 19:46    Post subject:  

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.

_________________
adobe flash is rubbish!
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/
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 1 [9 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Filesystem
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1153s ][ Queries: 13 (0.0419s) ][ GZIP on ]