Sunday, January 18, 2015

[LINUX_Newbies] Help with script and regex.

 

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

__._,_.___

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

.

__,_._,___

No comments:

Post a Comment