#21 2009-06-11 09:24

prologician
Member
Registered: 2009-01-30
Posts: 84

Re: Rearrange and Rename Folder Name Artist Album Pascal Script

You're right, you weren't far off. *^^*

I just now noticed your note about "Length(FileNameTestWord) > 4", where you're checking that there is a real filename before you try to rename it. This does have some problems, however.... it assumes that the extension is always 3 characters long, which isn't necessarily true.

A better way to do this test would be "WideLength(WideExtractBaseName(FileNameTestWord)) > 0". It makes the constant a 0 (which is not as strange as 4 in program code), and addresses the issue of file extension length. smile

Offline

#22 2009-06-11 12:11

Yogui
Member
Registered: 2007-09-27
Posts: 41

Re: Rearrange and Rename Folder Name Artist Album Pascal Script

Hi prologician,

I've updated from your last post, fix the ReplaceRegEx arguments were wrong roll and add some comments. cool

Seems that is working tongue

{File delete parent n grand parent folder string}

var
  Path: TStringsArray;
  Depth: Integer;
  FileNameTest: WideString;
  FileNameTestWord: WideString;
begin

  if WideFileExists(FilePath) then              {Process files only}
  begin
    Path:=WideSplitString(FilePath,'\');        {Create Array}
    Depth:=Length(Path);
    If (Depth>2) then                           {Check Parent and Grand Parent exist in Array}
    begin

      FileNameTest := WideReplaceStr(Path[Depth-1], Path[Depth-2], '');                   {Replace Parent (If Found)}
      FileNameTest := WideReplaceStr(FileNameTest, Path[Depth-3], '');                    {Replace Grand-Parent (If Found)}

      FileNameTestWord := ReplaceRegEx(FileNameTest, '(-_=|\s)' , '', False, False)       {RegEx to clean up a testword}
    
      If WideLength(WideExtractBaseName(FileNameTestWord)) > 0 then                       {Rename only if there is something left after replacing on the testword}
            FileName := FileNameTest
    end
  end;
end.

Offline

#23 2009-09-16 22:56

alext
Member
Registered: 2009-09-16
Posts: 2

Re: Rearrange and Rename Folder Name Artist Album Pascal Script

Hi,
I'm really struggling with something which seems very related to this but since I don't understand pascal I don't know how to modify this script for my needs.
Basically, I have songs files in a big folder in the format "Artist - Song.mp3". I want to rename them so that all the songs by the same artist appear in separate folders. ie I want to have "Artist/Song.mp3".
Please can you help. I know this must be simple but I've been searching the forum for ages and still have no idea.
Thanks!

Offline

#24 2009-09-17 02:34

narayan
Senior Member
Registered: 2009-02-08
Posts: 470

Re: Rearrange and Rename Folder Name Artist Album Pascal Script

Use the latest beta, and use the Rearrange rule in it. (No scripts required at all).

Use the following settings:

Delimiter:  " - "  (without the quotes).
New pattern: $1\$2
Skip extension [x] (ticked)

See help here: http://www.den4b.com/wiki/ReNamer:Rules:Rearrange
(See example-2 in Advanced Uses section, halfway down the page, )

Last edited by narayan (2009-09-17 03:24)

Offline

Board footer

Powered by FluxBB