Skip to main content

Thread: Parse filenames to text output


a little bit of background:

run music website, , every week hundreds of emails linked mp3s available download , posting. other users in community, i'm able parse links in email folder, output them text file, , use wget download everything. it's wonderful.

now, share files readers. want take selection of mp3s every week, put them in specified directory, , point script @ output formatted html, can dump html view window of our cms--quick, painless , automated, can post once week minimum effort.

here's example:

file: mos_def-quiet_dog.mp3

need resulting html output be:
code:
<a href="/music/mos_def-quiet_dog.mp3" target="_blank">mos def &ndash; &ldquo;quiet dog&rdquo; &ndash; [mp3]</a>
so text output on webpage is: mos def – “quiet dog” – [mp3]

far, use string
code:
find ./ -name "*.mp3" -print > goldrush.txt
output filenames in specific directory goldrush.txt. text file lists "./mos_def-quiet_dog.mp3" (i can't find way rid of './')

use string (which banged myself, hence sloppiness)
code:
awk '{print "/music/"mp3$""}' goldrush.txt
displays "/music/./mos_def-quiet_dog.mp3" (in terminal only, can't figure out how print new text file)

that's far i've gotten. try insert html code, syntax errors.

if can point me in right direction, or knows of "command line scripting dummies" tutorial, highly appreciative. first real cli work, , know nothing of scripting.

i trying remove ./ file earlier week.
don't have notes handy, might work or point in right direction:

1. cut -b 1,2 file.txt > output file
man cut (for different option)
-b byte , 1,2 remove 1st 2 bytes of file.txt , put result in output file

or

2. vi <file>
esc
: @ bottom of screen
s/\./\/s///g <enter>
esc
shift zz
(this vi editing.. @ man vi)


or

3. @ sed. found tutorial on web, , played needed.


Forum The Ubuntu Forum Community Ubuntu Official Flavours Support General Help [all variants] Parse filenames to text output


Ubuntu

Comments

Popular posts from this blog

Error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode - Raspberry Pi Forums

class MPU6050 has no member named begin

missing filename after '-o'