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:so text output on webpage is: mos def – “quiet dog” – [mp3]code:<a href="/music/mos_def-quiet_dog.mp3" target="_blank">mos def – “quiet dog” – [mp3]</a>
far, use stringoutput filenames in specific directory goldrush.txt. text file lists "./mos_def-quiet_dog.mp3" (i can't find way rid of './')code:find ./ -name "*.mp3" -print > goldrush.txt
use string (which banged myself, hence sloppiness)displays "/music/./mos_def-quiet_dog.mp3" (in terminal only, can't figure out how print new text file)code:awk '{print "/music/"mp3$""}' goldrush.txt
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
Post a Comment