Tuesday, January 20, 2015

Re: [LINUX_Newbies] Help with script and regex.

 

On 19/01/15 07:47 AM, Loyal Barber loyal_barber@yahoo.com [LINUX_Newbies] wrote:
 


On 1/19/2015 12:17 AM, Emil Payne ehspayne@yahoo.com [LINUX_Newbies] wrote:
 

I need (want) a script.
I screwed up renaming the sub-folders in my Pictures folder.
I want each folder to show the full path up to the Pictures folder
and to have brackets around each name.
I recursively named each one based upon it's parent, but it started
at the top folder and worked down vice the other way around (or
something weird like that).
I have a bunch of folders that look like the following:

<snip>

{12}«{04}«{2009}«{PHOTOS}«{Pictures}

Also, if you could explain it to me so I can try to do things myself.

Thanks;
Emil

<snip>
OMG.  Let me be the first to say this is NOT Newbie stuff.  I think you would be better to go find help
on either sed or awk.  What you are talking about is:
1. Take the string for the current working directory such as "/home/user/Pictures/PHOTOS/2009/04/12" and
stuff it into a string variable.
2. Remove the name of your home directory.
3. Cut the string into individual folder name strings starting with the last string and working toward the front of the
string.
4. Piece it back together placing curly braces around each folder name and putting << between each folder.
5. Remove and leading or trailing <<.
6. mv <current filename> <new file name> where <new file name> is the output from step 5.

I don't know either awk or sed that well so I am not your guy.  However, I have to ask:

*WHY?*

Just curious,

Loyal
I've looked up sed, awk & grep online, but they all work with files (the web pages, that is). How do I get them to work with a directory name?

Emil

__._,_.___

Posted by: Emil Payne <ehspayne@yahoo.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (11)
To unsubscribe from this list, please email LINUX_Newbies-unsubscribe@yahoogroups.com & you will be removed.

.

__,_._,___

No comments:

Post a Comment