Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 01-15-2008, 10:36 PM   #1
Registered: Nov 2003
Location: NC, USA
Distribution: unbuntu breazy
Posts: 142

Rep: Reputation: 15
mass file renaming sed/awk/mv

The more I look at sed & awk, the more confused I become. I can't seem to get my hands around it. It appears to be a powerful tool for editing, but it appears you can really screw stuff up and irreparably damage your work. The process may even be a multi step process. I would not mind doing it by hand, but there are hundreds of files. Just not sure how to start

I would like them to have a similar structure like the following file:
ShopNotes #001 - Shop Built Router Table.pdf <== Shop & Notes are capitalized & has a three digit numeric.
The Art Of Woodworking #013 - Wood Turning.pdf
Woodworking Plans - Boat Plans Canoe.pdf
Fine Woodworking - Built-In Furniture.pdf

The sample of files that need conversion:
Shopnotes #05 - Turned Tool Handles.pdf <== two digit numerice and notes is not capitalized
ShopNotes #106 Understanding Lumber _ Plywood.pdf <== has the underscore in the name
Woodworking - ShopNotes #62 - Box Joint Jig.pdf <<==Woodworking leads in.
The Art Of Woodworking Vol 19 - Advanced Routing.pdf
Woodworking _Plans_ Bending.Wood.pdf

also, show any that error out because duplicates are found.
Old 01-15-2008, 11:11 PM   #2
Senior Member
Registered: Oct 2003
Posts: 2,575

Rep: Reputation: 220Reputation: 220Reputation: 220
For the life of me, I can't detect any systematic pattern in what you are trying to do. If you can't state the particular systematic pattern change you want to accomplish, you will never be able to do the manipulation with those tools.

You might want to look at the kde application, krename. It's a very powerful graphical file renaming utility that can use, among other things, regular expressions, which is probably what you need. With krename, you can also preview how the changes will look before they are made so you can avoid doing something you don't want to do.
Old 01-16-2008, 06:53 PM   #3
Registered: Nov 2003
Location: NC, USA
Distribution: unbuntu breazy
Posts: 142

Original Poster
Rep: Reputation: 15
Thanks. I guess a multi step process is indeed in order.

what do you think about this?

Then the first step for me then is to make sure any with a lower case “Shopnotes” be capitalized to “ShopNotes” then have any with a two digit number add a leading zero “0”

so that

Shopnotes #05 - Turned Tool Handles.pdf


ShopNotes #05 - Turned Tool Handles.pdf

then add the leading 0 so then I am left with

ShopNotes #005 - Turned Tool Handles.pdf

Then I would want to strip off “Woodworking - “ from other files so that they have both “Woodworking” & any convention of “ShopNotes”. Hopefully, this will keep other files from being targeted.

Woodworking - ShopNotes #056 - Circular Saw Miter Station.pdf


ShopNotes #056 - Circular Saw Miter Station.pdf

Last edited by asalford; 01-16-2008 at 09:02 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash - Mass file renaming problem smudge|lala Linux - Software 2 02-14-2007 07:02 PM
How exclude | from txt.file using awk or sed? sarajevo Programming 2 08-21-2006 08:26 AM
ssimple shell script to parse a file ~sed or awk stevie_velvet Programming 7 07-14-2006 04:41 AM
how to delete duplicates entries in xml file using sed/awk/sort ? catzilla Linux - Software 1 10-28-2005 03:57 PM
Help with a script to edit text file (awk? sed?) rickh Linux - Newbie 8 04-21-2005 09:24 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:00 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration