Monday, January 19, 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
The long string with the brackets and repetitive names is already created and sitting there. I just need to remove the repetitive information using the criteria mentioned.  It does not need to read anything in the directory structure, just the current directory name.

This is part of a huge consolidation / categorization I am doing on all my pictures. Later I will change the directories back by removing everything passed (and including) the first '«'.

I could do it manually, but there are 694 directories.

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 (3)
To unsubscribe from this list, please email LINUX_Newbies-unsubscribe@yahoogroups.com & you will be removed.

.

__,_._,___

No comments:

Post a Comment