4

I want to monitor (by cron, I got that part covered :P) new audio files in folders so I can add them toa separate XML files which act as an podcast RSS feed. The file structure looks like this:

- Podcasts
-- Show number one
--- Audio file of the show for week one.mp3
--- Audio file of the show for week two.mp3
-- Show number two
--- Audio file of the show for week one.mp3
--- Audio file of the show for week two.mp3
-- So on

The audio file creation is automated by a computer in our studio, that uploads them to our ubuntu server so the files are accessible publicly. Now, the idea is to make everything automated because we only have volounteers and they're lazy! :)

Now, the script would need to monitor for new folders into "podcast" and new audio in "show number X" folders. Everytime there is a new show folder, I need to create a new XML file for that specific show podcast and everytime there is a new audio in a show, I need to add it to the show's XML.

Now I know the structure of XMLs just fine, I'm just completely in the dark when it comes to bash scripts. How can I make a script that looks for new file and folders? Can the script write within an XML file?

Regards,

2

Take a look at iwatch

apt-get install iwatch

From man page:

iwatch - a realtime filesystem monitor / monitor any changes in directories/files specified

Example:

iwatch /tmp -e create -c <your command/script>

Explain:

watch folder /tmp for new created files/folders. For each new created file/folder run command your command/script

In your case you could run a script which generate this XML files.

I can't give you a more detailed answer, but maybe it's a good start point for better answers :)

1

There might be other ways to edit XML files in bash, but something like XMLStarlet might work for you. Sorry this answer is split out between me and Wolfy.

  • Will be checking this soon enough, I'll get back with results! :) – Jean-Philippe Murray Jun 12 '13 at 15:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.