Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
...and makes folders from those file names in the following syntax:
Location-YEAR-MN-DY- Subject -BLH
The "BLH" part needs to be indiscriminately attached to every folder name.
Basically it'll take some Regex to parse the data from the file name and reorganize it into the folder name...and I think there will have to be a loop statement like do-while...can anyone help me?
Unless reinventing the wheel is something you just got to do, did you check LQ, Freshmeat or Sourceforge for apps that already can do that? Besides filenames like "Mon_Da_YEAR_Sub_ject_Sub_ject_Location_side_1_or_2.mp3" aren't reliable and easy to work with (wrt IFS). If MP3s are tagged "right" then getting the mp3info and working on that would be *way* "safer" IMHO. The "BLH" part isn't something you would even need sed for. Maybe it's best to post whatever (pseudo) script you've got right now?..
Quote:
Originally Posted by ifeatu
Basically it'll take some Regex to parse the data from the file name and reorganize it into the folder name...
No challenge for you as it seems you recently bought ISBN 9780596528126 :-]
okay...so I took your advise and took a stab at it...I ended up having to use a batch file in DOS for the folder creation part...then I installed GNU Sed for DOS and took a stab at the RegEx...here is where I got stuck:
So you have the month (.*) followed by the day ([0-9]{1,2}) followed by the year ([0-9]{4}) followed by a subject (.*) followed by a location (Vallejo,vallejo, Berkeley,berkeley, UC, Union City) followed by the word "side" followed by a 1 or 2
sed -r 's/(.*)([0-9]{2})\s*_\s*([0-9]{4})\s*_\s*(.*)\s*([vallejo][.*])\s*(side)\s*_\s*([1,2])(.*)/\3-\1-\2-\4/' test2.txt
> test3.txt
I think its pretty obvious where I'm running into my problem, I can't seem to get my syntax right for the location...can anyone help?
The line above returns absolutely nothing, it returns the data precisely as it is read.
That's a bit advanced for me, but I notice a couple of things:
1. in your data you have Vallejo, your sed uses vallejo (case is different)
2. Aug_04_1991B_Moving_out_alive_soul_Vallejo_side_1.mp3 & Aug_04_1991B_Moving_out_alive_soul_Vallejo_side_2.mp3 do not have an underscore after the year component.
That's a bit advanced for me, but I notice a couple of things:
1. in your data you have Vallejo, your sed uses vallejo (case is different)
2. Aug_04_1991B_Moving_out_alive_soul_Vallejo_side_1.mp3 & Aug_04_1991B_Moving_out_alive_soul_Vallejo_side_2.mp3 do not have an underscore after the year component.
therein lies a portion of the challenge. The regex needs to make provisions for the B or A that some times delimits the year...I understand that the data isn't at all pretty...but in this circumstance, reinventing the wheel is an absolute neccesity.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.