Skip to Content
It is currently July 6th, 2022, 8:41 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: July 23rd, 2017, 2:11 pm 
Offline
Senior User
Senior User

Joined: September 12th, 2012, 9:42 pm
Posts: 94
Is it possible to delete a TXT file at the end of a pal script? Is so, can you please tell me how?

Thank you in advance!


Top
 Profile  
Reply with quote  
PostPosted: July 23rd, 2017, 9:53 pm 
Offline
SVS Member
SVS Member

Joined: October 15th, 2003, 11:59 pm
Posts: 4744
Location: Los Angeles - A Little West Of Nashville
Code:
if (DeleteFile('C:/news/test.txt')) then
 WriteLN('file deleted')
else
 WriteLN('file NOT deleted');

_________________
- DJ Dee
- Spacial Volunteer Support (SVS)
- Custom PAL services: www.palscripts.com
- http://www.AlternativeHD.com
- http://www.lahotcountry.com


Top
 Profile  
Reply with quote  
PostPosted: August 19th, 2017, 8:24 am 
Offline
Senior User
Senior User

Joined: January 26th, 2006, 7:33 pm
Posts: 195
Location: Douglas, Isle of Man, UK
How about if you want to move or delete a show after it's played - can that be done via a PAL too?

_________________
Its all about the music..
https://www.1mix.co.uk


Top
 Profile  
Reply with quote  
PostPosted: August 19th, 2017, 11:27 am 
Offline
SVS Member
SVS Member

Joined: October 15th, 2003, 11:59 pm
Posts: 4744
Location: Los Angeles - A Little West Of Nashville
Your question is too vague .. be more specific.

_________________
- DJ Dee
- Spacial Volunteer Support (SVS)
- Custom PAL services: www.palscripts.com
- http://www.AlternativeHD.com
- http://www.lahotcountry.com


Top
 Profile  
Reply with quote  
PostPosted: August 21st, 2017, 8:58 am 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 8306
Location: Cologne (Germany)
Busby wrote:
How about if you want to move or delete a show after it's played - can that be done via a PAL too?

If by "show" you mean a single track/file in SAM's library, SAM has a function for that purpose already built-in at the Songinfo.

_________________
Benedikt Bauer - SVS (Spacial Volunteer Support)

Shop for readymade PAL scripts by countrywesterndj - Or get a custom script made by me (or others)

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Sourcecode


Top
 Profile  
Reply with quote  
PostPosted: May 10th, 2021, 7:50 am 
Offline
Senior User
Senior User

Joined: January 26th, 2006, 7:33 pm
Posts: 195
Location: Douglas, Isle of Man, UK
So if I want to move a file from 1 folder to another after it's played, could you give me an example of that please..

At pesent I'm using batch files to move shows after they have played to a 'replay' folder and it would be great if this could be automated via the show PAL.

_________________
Its all about the music..
https://www.1mix.co.uk


Top
 Profile  
Reply with quote  
PostPosted: May 10th, 2021, 9:00 am 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 8306
Location: Cologne (Germany)
"Move" is just a fancy name for a batch action that first copies, then deletes.

In PAL-Terms:
Find your "show" file after it's played, then use CopyFile to copy source File to destination File, then use DeleteFile on the source File you copied from.
Once you're done, you have successfully moved source File to destination File. At that point source File should be gone and destination File should be in your archive folder.

Do you need to move the files on your harddisk, though? Can't you just use SAM's categories for that purpose and move tracks between categories instead?

_________________
Benedikt Bauer - SVS (Spacial Volunteer Support)

Shop for readymade PAL scripts by countrywesterndj - Or get a custom script made by me (or others)

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Sourcecode


Top
 Profile  
Reply with quote  
PostPosted: May 10th, 2021, 3:06 pm 
Offline
Senior User
Senior User

Joined: January 26th, 2006, 7:33 pm
Posts: 195
Location: Douglas, Isle of Man, UK
That's what I'm doing using batch files run under windows task scheduler

Code:
cd C:\Radio\Revealed Recordings\part 01\Replay
xcopy *.mp3 "c:\Radio\Replay House\" /y
del *.mp3
cd C:\


Can you give me the syntax for doing that with a PAL please - this is a typical show

Code:
//Set integer value to number of parts in show
const PARTS : Integer = 1;
//Set integer value to "1" for weeks of month to run script
const WEEK_ONE   : Integer = 1;
const WEEK_TWO   : Integer = 0;
const WEEK_THREE : Integer = 0;
const WEEK_FOUR  : Integer = 0;
const WEEK_FIVE  : Integer = 0;

var Song : TSongInfo;
var Present : DateTime;
var curPart, Year, Month, Day, WeekOfMonth : Integer;
var D : string;
var Artist : string;
var Show : string;
var Week : array[0..4] of Integer;

// Settings, Artist has to be EXACTLY like the folder-name.
Artist := 'Meko Hadzic';
Show := 'High Definition On 1Mix Radio..';

//Check if proper week to run
PAL.LockExecution;

Week[0] := WEEK_ONE;
Week[1] := WEEK_TWO;
Week[2] := WEEK_THREE;
Week[3] := WEEK_FOUR;
Week[4] := WEEK_FIVE;

WeekOfMonth := 0;

Present := Now;
DecodeDate(Present, Year, Month, Day);

while Day > 0 do
  begin
    Day := Day - 7;
    if Day > 0 then
      WeekOfMonth := WeekOfMonth + 1;
end;

PAL.UnlockExecution;

//if proper week, continue
while (Week[WeekOfMonth] = 1) do
  begin
    SubDir['C:\Radio\' + Artist].Rescan;
    curPart := 0;

    //Wait Top of the hour
    PAL.WaitForTime('XX:00:00');
    PAL.LockExecution;
    Queue.Clear;
    //Add files to top of queue in reverse order so last loaded plays first
    //Queue.Addfile ('C:\Radio\'+Artist+'\id\id2.mp3',ipTop);
    //Dir['C:\Radio\Jingles&Wipes'].QueueTop(smRandom, NoRules);
    //Dir['C:\Radio\'+Artist+'\part 04'].QueueTop(smLRP, NoRules);
    //Dir['C:\Radio\Jingles&Wipes'].QueueTop(smRandom, NoRules);
    //Dir['C:\Radio\'+Artist+'\part 03'].QueueTop(smLRP, NoRules);
    //Dir['C:\Radio\Jingles&Wipes'].QueueTop(smRandom, NoRules);
    //Dir['C:\Radio\'+Artist+'\part 02'].QueueTop(smLRP, NoRules);
    //Dir['C:\Radio\Jingles&Wipes'].QueueTop(smRandom, NoRules);
    Dir['C:\Radio\'+Artist+'\part 01'].QueueTop(smLRP, NoRules);
    //Queue.Addfile ('C:\Radio\'+Artist+'\id\id1.mp3',ipTop);
    Dir['C:\Radio\Jingles&Wipes'].QueueTop(smRandom, NoRules);

    //Fade into jingle, which was loaded last
    //Check for incorrectly loaded track and eject if it exists
    if QueuedPlayer <> NIL then
      QueuedPlayer.Eject;
    //Fade into jingle, which was loaded last
    ActivePlayer.FadeToNext;
    PAL.UnlockExecution;
    PAL.WaitForPlayCount(2);
    // Inserting title and date
    while (curPart < PARTS) do
      begin
        Song := TSongInfo.Create;
        DecodeDate(Present, Year, Month, Day);
        D := (IntToStr(Day)) + '.' + (IntToStr(Month)) + '.' + (IntToStr(Year));
        Song['artist'] := Artist + ' @MekoHadzic';
        Song['title'] := Show + ' (' + D + ') Listen now http://bit.ly/2IZUaOU';
        Encoders.SongChange(Song);
        Song.Free;
        curPart := curPart + 1;
        //For multi-part shows otherwise zero
        PAL.WaitForPlayCount(0);
    end;
    Week[WeekOfMonth] := 0;
end;


BTW - I didn't write that myself, I had help.

Unlike I would guess, the majority of SAM owners, my station only plays pre-recorded shows, which are mostly single or perhaps 2 files, so I don't use catagories. but when no show is scheduled, one in the 'replay' folder is loaded via a clockwheel.

It would be good to incorporate some code in each show PAL that would move a show after it's played, into the 'replay' folder.

Thanks in advance..

_________________
Its all about the music..
https://www.1mix.co.uk


Top
 Profile  
Reply with quote  
PostPosted: May 10th, 2021, 6:02 pm 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 8306
Location: Cologne (Germany)
Whatever works for you. The directory approach could indeed work better for you if you play long-format shows and never fill stuff up with short tracks.
You could've gotten away way cheaper by just using Winamp, though.

Does your script really work the way it's intended? It looks to me like it announces the track you currrently played after it is done playing the track.

The easiest way to delete/move your tracks is by replacing every line where you add a new track to the queue and instead store the track in a variable first and then add that song to the queue.

i.e.: for a single track add this at the top in the VAR section:
Code:
VAR track: TSongInfo;
VAR copySuccessful : Boolean = False;

and replace the DIR['C:\'].QueueBottom(smRandom, NoRules); by this:
Code:
track := DIR['C:\'].ChooseSong(smRandom, NoRules);l
Queue.AddSong(track, ipBottom);


Then add this after the end of your loop:
Code:
copySuccessful := CopyFile(track['filename'], 'C:\Insert-full-new-path-here-inlcuding-directories-and-filename.mp3', False);
IF copySuccessful THEN
  DeleteFile(track['filename']);


If you have an hour to learn about PAL scripting, you could check out the Quick Start guide, especially the section on string handling and play with that for a bit.
Then you can go further and automatically choose the destination path based on the source path. (The filename property includes the full path, not only the filename, you could use Pos and Copy to get yourself only the filename and append that to the end of a destination folder, but it's too late for me to think of that right now. I'd need to play with it for half an hour or so before I remember how to do that in PAL. I'm a software developer by trade, but I don't write PAL/Delphi code that much anymore and PAL only supports a very limited subset of the programming language it's built in itself)

_________________
Benedikt Bauer - SVS (Spacial Volunteer Support)

Shop for readymade PAL scripts by countrywesterndj - Or get a custom script made by me (or others)

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Sourcecode


Top
 Profile  
Reply with quote  
PostPosted: May 11th, 2021, 7:24 am 
Offline
Senior User
Senior User

Joined: January 26th, 2006, 7:33 pm
Posts: 195
Location: Douglas, Isle of Man, UK
I'm afraid I'm 73 and would struggle to lean PAL scripting at my age..

Would you mind amending my PAL to do what I need, but if I can explain, again unlike most people on here, my station is different as there are no fixed file names, they change every week, but the artists folders only contain their shows, so using wildcards would work.

I'm happy to pay for you to do that as it would make my life so much easier.

On another matter, as you know, if there are ID3 tags in a file, that's what SAM uses for it's metadata, so I am having to rename the streams as artists frequently forget.

Do you know of a way of copying the file name to the tags because I can automate renaming the file, but not the tag.

Thanks in advance..

_________________
Its all about the music..
https://www.1mix.co.uk


Top
 Profile  
Reply with quote  
PostPosted: May 11th, 2021, 8:51 am 
Offline
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 8306
Location: Cologne (Germany)
Busby wrote:
I'm afraid I'm 73 and would struggle to lean PAL scripting at my age..

Struggle, sure, but that's no different than an 18 year old. In fact you're probably more likely to learn it as you are more used to how computers work than the kids today who think everything just magically works.

Busby wrote:
Would you mind amending my PAL to do what I need, but if I can explain, again unlike most people on here, my station is different as there are no fixed file names, they change every week, but the artists folders only contain their shows, so using wildcards would work.

PAL doesn't support wildcards in any place.

Busby wrote:
Do you know of a way of copying the file name to the tags because I can automate renaming the file, but not the tag.

There's hundreds of ID3 tag editors that can do that. One option would be mp3tag https://help.mp3tag.de/main_converter.html

Busby wrote:
I'm happy to pay for you to do that as it would make my life so much easier.

Sure, send me a PM or an email and we can discuss that option.

_________________
Benedikt Bauer - SVS (Spacial Volunteer Support)

Shop for readymade PAL scripts by countrywesterndj - Or get a custom script made by me (or others)

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Sourcecode


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group