Exporting Script


#1

Hello.

Every Sunday morning, I have to post a couple files up to a website. While retaining the previous 8 weeks in descending order.

I have an export script right now, that generates the audio.xspf file correctly, but it requires a couple manual steps before execution.

  1. select latest audio file
  2. run Action to generate tags, and correctly name file for web posting
  3. sort file names in descending order
  4. select all files
  5. run the export "xspf generator"

xspf.mte

$filename(audio.xspf)<?xml version="1.0" encoding="uft-8"?>
<playlist>
  <tracklist>$loop(a)
    <location>backend/audio/%_filename_ext%</location>
    <annotation>%title% - %artist%</annotation>
  <tracklist>$loopend()
</playlist>

Is there an export command that I can add to the xspf generator that will select all files, and sort them by filename in descending order? I want to reduce the chances for error since I'm going to be handing the process off to the operators soon.

Thank you for your help.


Extract weekdays and month names from timestamp
#2

Use $loop(%_filename%) or $loop(%_path%) instead of $loop(a) for correct sorting.


#3

Thanks For trying Pone...

Unfortunately, the %_filename% or %_path% don't appear to sort the files in the order of newest to oldest. That is why I use the screen layout sort of $loop(a).

The list of files defaults to before processing:
2012-02-05_Title
2012-02-12_Title
2012-02-19_Title
2012-02-26_Title
(new) 2012-03-05 - junk - Artist - Title
(new) 2012-03-02 - junk - Artist - Title
(late arrival) 2012-03-04 - junk - Artist - Title (2012-03-06 arrival)
(new) 2012-03-06 - junk - Artist - Title
(replacement) 2012-03-02 - junk - Artist - Title

The action file I have converts the names to the right format, and places the tags, but the sort is still incorrect.

I need the output sort to be this way (newesst to oldest).
2012-03-06_Title
2012-03-05_Title
2012-03-04_Title
2012-03-02_Title
...


#4

$loop(%_filename%) and $loop(%_path%) sort by filename and path.
The problem seems to be your (new) / (late arrival) / (replacement) expressions in your filenames. These crash your own system for sorting after date.

try:
$loop($regexp(%_filename%,^\D+(\d),$1))
that should ignore everything before the first number

I don't know what these date means, but maybe these placeholder can also help you for sorting your files:
%_file_create_date% Short creation date
%_file_create_datetime% Long creation date

%_file_mod_date% Short modification date
%_file_mod_datetime% Long modification date

EDIT:
sorting from newest to oldest is complicated as you have to reverse the sorting.
If you can extract the numbers, it is possible.

$loop($sub(99999999,$regexp(%_filename%,.?(\d\d\d\d)-(\d\d)-(\d\d).,$1$2$3)))
This should work if all files have the date in the YYYY-MM-DD format somewhere in the title. For files which have the more that one date (like I see it in your example) the first date will be taken for sorting. If you want the second date, leave the ? away in the $loop string.


#5

Hi Pone

Thanks for your help on this. The $loop($sub.... worked in the test run. I'll try it on the production script later. I think I might just save the output to a filesorting feild for later use too.

Sorry the second date added confusion. I was orriginally planning to show why I can't count on the placeholders. I forgot to delete that part of the line.
All I can go on is the information provided in the filenames, which thankfully is always the same pattern.
After the action script runs. The filenames are just CodeDate_Title.