Wednesday, January 21, 2015

Re: [LINUX_Newbies] Help with script and regex.

 

On 19/01/15 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:

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

What I need to do is:

1. Check the name to see if it needs to be fixed by seeing if it
ends with '}}}}'.
2. Find the first '}'; find the « before the first '}}'; erase
everything between the two.
3. Repeat using '}}' and '}}}'.
4. Repeat using '}}}' and '}}}}'.
5. Remove the last three '}}}' from the remaining '}}}}'.
6. Add brackets around the first part.
a. Place '{' at the beginning.
b. Place '}' before first '«'.

Thus ending up with:

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

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

Thanks;
Emil


Got it.

I took the original

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

and replaced every phrase with a variable

[X1]«{[X2]}«{[X3]«{[X4]}}«{[X5]«{[X6]}«{[X7]«{[X8]}}}«{[X9]«{[X10]}«{[X11]«{[X12]}}«{[X13]«{[X14]}«{[X15]«{[X16]}}}}

then put it back together

[X4]«[X2]«[X1]«[X8]«[X16]

thus getting

2009«04«12«PHOTOS«Pictures








__._,_.___

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

.

__,_._,___

No comments:

Post a Comment