#1 2006-04-09 10:38

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,375

New PascalScript rule

Next version will include a scripting rule; I'm already working on it!

It will allow users to program their own renaming rule using Delphi/Pascal syntax and functionality smile Can anyone program in Delphi?

Soon enough, I will release a first Beta version of it, and I would like people to test it and try it out...

Join the forum, to get connected :yes:

Offline

#2 2006-04-13 19:36

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,375

Re: New PascalScript rule

Good News!!!

Here is the first test version of ReNamer with new PascalScript rule big_smile

http://www.redbrick.dcu.ie/~den4b/Proje … erBeta.zip

I'm more then certain that no bugs will be found, since I did test it a lot! But I want users to try it out, and tell me what they think?

Any suggestions/questions concerning PascalScript rule should be posted here, thanks smile

Offline

#3 2006-04-28 11:05

LawOfNonContradiction
Member
From: USA
Registered: 2006-04-28
Posts: 45

Re: New PascalScript rule

I'm still learning RegEx (for Exim).  This seems like a powerful feature... perhaps you'll create a subforum "PascalScript respository"? wink   That way power users can show off, non programming power users can benefit. 

cheers

cool

Offline

#4 2006-04-28 11:15

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,375

Re: New PascalScript rule

Law of NonContradiction wrote:

perhaps you'll create a subforum "PascalScript repository"? wink

I probably will, but it will be a bit later, once the forum fills up a bit... it's just starting off big_smile

Offline

#5 2006-05-03 03:50

dloneranger
Senior Member
From: Birmingham, UK
Registered: 2006-05-03
Posts: 122

Re: New PascalScript rule

Great new feature, saves me having to knock up one time delphi programmes
This is the kind of program I've being meaning to write for a while, but I never seem to get the time

Being able to just insert my own code is very useful
Though a list of what I can type would be handy tongue

Can I for example access the (don't know what your using but a tstringlist might be it)
list of files to be renamed and sort them? eg FileToBeRenamed.Sort or SortByFilename(ascending)

How about accessing the folder name of the file?
(this is going to assume that path=the full foldername eg c:\document...\my pic..\party and folder =party)
So you could do something like
var i:integer;
begin
i:=i+1;
filename:= folder+' '+inttostr(i);
end


Thanks

Offline

#6 2006-05-04 11:23

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,375

Re: New PascalScript rule

Hi dloneranger,

dloneranger wrote:

Can I for example access the (don't know what your using but a tstringlist might be it)
list of files to be renamed and sort them? eg FileToBeRenamed.Sort or SortByFilename(ascending)

No, the FileName and FilePath are the only Global/Registered variables that you access from within the PascalScript rule. It is much safer this way, since it eliminates the possibility of users breaking the whole operation wink

There are loads of Sort options, did you not find the one you want?  By which criteria do you want to sort your files?

dloneranger wrote:

How about accessing the folder name of the file?

You can access it via the meta tag :File_FolderName: , or you can use this code:

var
  I: Integer;
  Folder: string;
begin
  I := I + 1;
  Folder := ExtractFileDir(FilePath);
  Folder := ExtractFileName(Folder);
  FileName := Folder + ' ' + IntToStr(I);
end.

Offline

#7 2006-05-05 17:00

dloneranger
Senior Member
From: Birmingham, UK
Registered: 2006-05-03
Posts: 122

Re: New PascalScript rule

Denis Kozlov wrote:

There are loads of Sort options, did you not find the one you want?  By which criteria do you want to sort your files?

No real need, I was just curious.

dloneranger wrote:

How about accessing the folder name of the file?
You can access it via the meta tag :File_FolderName: , or you can use this code:

var
  I: Integer;
  Folder: string;
begin
  I := I + 1;
  Folder := ExtractFileDir(FilePath);
  Folder := ExtractFileName(Folder);
  FileName := Folder + ' ' + IntToStr(I);
end.

Hmm, so is it possible to change the folder as well?
To do something like
extract the first word of the filename, make a new folder with that name and add that name to Filepath.

or more simply put

var Folder:string;
begin
  Folder:= Filepath+'\'+copy(filename,1,6);
  ForceDirectories(folder)
  Filepath := Folder
end.

Offline

#8 2006-05-05 17:22

dloneranger
Senior Member
From: Birmingham, UK
Registered: 2006-05-03
Posts: 122

Re: New PascalScript rule

Just tried it and the folder doesn't get created.
No probs

You've got me interested in this pascalscript though
It could save a lot of time - a simple pascal interpretor could come in handy
Faster than loading up BDS and a lot easier to transport around

Honestly, the amount of times I wish I had Delphi installed on clients pc's :no:

Offline

#9 2006-05-06 21:45

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,375

Re: New PascalScript rule

dloneranger wrote:

Hmm, so is it possible to change the folder as well? To do something like extract the first word of the filename, make a new folder with that name and add that name to Filepath. Or more simply put:

var Folder:string;
begin
  Folder:= Filepath+'\'+copy(filename,1,6);
  ForceDirectories(folder)
  Filepath := Folder
end.

As it written in the PascalScript help:
Changes to the FileName variable will be treated as changes to the New Name of the File.
FileName - filename of the currently processing file, including extension;
FilePath - path of the currently processing file;

FilePath is provided only for information, so you can read the file contents for example. Even if you change it - changes will NOT be affect anything. The FileName variable is the only variable that will affect the new filename.

So, you can't really change the file's folder structure... But, there is one trick, you can APPEND the folder structure, i.e. if you have file FilePath = "c:\temp\file.txt", then FileName = "file.txt", and if you set  FileName = "folder\file.txt", then it will be appended to the "c:\temp\", and so you'll get the file to be renamed to "c:\temp\folder\file.txt" ;D

That will do the trick:

begin
  FileName := Copy(FileName,1,6) + '\' + FileName;
end.

Note: ReNamer will give you a warning, saying that the new name is invalid because it will contain '\' (forbidden character), but it will still rename (folders will be automatically created)!

Offline

#10 2006-05-07 09:45

dloneranger
Senior Member
From: Birmingham, UK
Registered: 2006-05-03
Posts: 122

Re: New PascalScript rule

Um, the PascalScript help?

Can't say I've seen that anywhere :conf:

But what you've written sorts me out ok
Thanks

Offline

Board footer

Powered by FluxBB