Hi there,
I am using AMC for about a year now, and my movie-db grew to more than 600 movies. It's great to have that URL field pointing to the files, so I can use AMC or even ANTviewer to directly play my selection.
I recently restructured my folder-strategy, and what annoyed me there is that cryptic name, the releases have when coming out of the download-pipe.
Those cryptic filenames/paths like \Escape.2.2008.1080p.BluRay.AC3.DL.x264.dxva-HDC\Escape.2.2008.1080p.BluRay.AC3.DL.x264.dxva-HDC.mkv
could be elegantly renamed to its values in the datebase.
So scripting a rename of the paths and files to a much shorter an uniforming look like for example \Escape.2\Escape.2.2008.mkv (and of course updating the URL-field) would be a great feature. It would save me countless hours doing that by hand.
I saw on the site a tool named antrenamer, and I wished it would do that... You just need to merge that into AMC
Greeting and thanks for that program,
Don
Rename Files/Folders based upon database entries
Hi,
Actually using AMC's scripting engine, you can already do it.
There is a "MoveFile" function that allows to rename/move a file.
So all what you have to do is to build a new path & name, call MoveFile, and if it succeeds also update the "URL" field with the new path & name.
If you can't write the script yourself, maybe I (or someone else who pass here before) can do it if you can say exactly what you want (i.e. how should the files be renamed).
Actually using AMC's scripting engine, you can already do it.
There is a "MoveFile" function that allows to rename/move a file.
So all what you have to do is to build a new path & name, call MoveFile, and if it succeeds also update the "URL" field with the new path & name.
If you can't write the script yourself, maybe I (or someone else who pass here before) can do it if you can say exactly what you want (i.e. how should the files be renamed).
Hey,
that would be amazing, if somebody could to this for me. I am yet new to programming scripts and would end up stuck, I think.
I have my movies in some separate paths like
d:\storage\movies-a
d:\storage\movies-b
d:\storage\movies-animation
d:\storage\movies-classics
and in this structure are movies each in a separate folder, like:
d:\storage\movies-b\The.Escape.2.2008.1080p.BluRay.AC3.DL.x264.dxva-HDC\Escape.2.2008.1080p.BluRay.AC3.DL.x264.dxva-HDC.mkv
What I would like, is a rename of the last directory to:
%name_translated%_%year% (with removed prefixes)
And the file in it, should read:
%name_org%_%languages%.extension (with removed prefixes)
and update the URLfield with:
d:\storage\movies-b\Flucht_2_2008\Escape_2_Ger_Eng.mkv
Thanks for any hint in the right direction!
Don
that would be amazing, if somebody could to this for me. I am yet new to programming scripts and would end up stuck, I think.
I have my movies in some separate paths like
d:\storage\movies-a
d:\storage\movies-b
d:\storage\movies-animation
d:\storage\movies-classics
and in this structure are movies each in a separate folder, like:
d:\storage\movies-b\The.Escape.2.2008.1080p.BluRay.AC3.DL.x264.dxva-HDC\Escape.2.2008.1080p.BluRay.AC3.DL.x264.dxva-HDC.mkv
What I would like, is a rename of the last directory to:
%name_translated%_%year% (with removed prefixes)
And the file in it, should read:
%name_org%_%languages%.extension (with removed prefixes)
and update the URLfield with:
d:\storage\movies-b\Flucht_2_2008\Escape_2_Ger_Eng.mkv
Thanks for any hint in the right direction!
Don
I was going to say that I do not have time now, but if I do not do it now I'll never do it
And it could probably be useful for other people, for similar cases:
Be careful when testing
This will fail if there are invalid characters in titles (like "?" etc.)
To make things clean, the StringReplace function should be used to handle these cases.
Normally it updates the URL field only when file was renamed, but I may have missed something, so do the test on few movies first.
About the prefix removed, extract code has to be added to handle that, either write it or correct by hand later
(again with StringReplace it should be easy)
And it could probably be useful for other people, for similar cases:
Code: Select all
program NewScript;
var
url, newurl, root, folder, newfolder: string;
begin
url := GetField(fieldUrl);
folder := ExtractFilePath(url);
root := ExtractFilePath(Copy(folder, 1, Length(folder) - 1));
newurl := folder + GetField(fieldOriginalTitle) + '_' + GetField(fieldLanguages) + ExtractFileExt(url);
if MoveFile(url, newurl) then
begin
SetField(fieldUrl, newurl);
url := newurl;
newfolder := root + GetField(fieldTranslatedTitle) + '_' + GetField(fieldYear);
if MoveFile(Copy(folder, 1, Length(folder) - 1), newfolder) then
begin
newurl := newfolder + '\' + ExtractFileName(url);
SetField(fieldUrl, newurl);
end;
end;
end.
This will fail if there are invalid characters in titles (like "?" etc.)
To make things clean, the StringReplace function should be used to handle these cases.
Normally it updates the URL field only when file was renamed, but I may have missed something, so do the test on few movies first.
About the prefix removed, extract code has to be added to handle that, either write it or correct by hand later
(again with StringReplace it should be easy)
Awesome!!
Where can I find a listing of variables and functions from that scripting?
I tried this out, it does actually rename the files, but does not change the parents path.
So this:
D:\HS_downloads\Choke.Der.Simulant.2008.German.DL.DTS.1080p.BluRay.x264-R0CKED\Choke.Der.Simulant.2008.German.DL.DTS.1080p.BluRay.x264-R0CKED.mkv
becomes:
D:\HS_downloads\Choke.Der.Simulant.2008.German.DL.DTS.1080p.BluRay.x264-R0CKED\Choke_German, English.mkv
It does update the URLfield so that it still links correct!
Thank you, Antoine, for taking your time - you should do paypal or such, so I could buy you a beer or do you prefer wine?
Don
Where can I find a listing of variables and functions from that scripting?
I tried this out, it does actually rename the files, but does not change the parents path.
So this:
D:\HS_downloads\Choke.Der.Simulant.2008.German.DL.DTS.1080p.BluRay.x264-R0CKED\Choke.Der.Simulant.2008.German.DL.DTS.1080p.BluRay.x264-R0CKED.mkv
becomes:
D:\HS_downloads\Choke.Der.Simulant.2008.German.DL.DTS.1080p.BluRay.x264-R0CKED\Choke_German, English.mkv
It does update the URLfield so that it still links correct!
Thank you, Antoine, for taking your time - you should do paypal or such, so I could buy you a beer or do you prefer wine?
Don
Hmm normally it should update the folder too.
Maybe there was an invalid character in title field?
Did you try on more than one movie?
You can also set a breakpoint by clicking in the margin of the script editor, and advance line by line, checking contents of each variable to see if it is correct.
You can find more info on script in the help file, in "technical info" section.
But some of the functions used are are standard Delphi functions so I did not include these in the help file.
Maybe there was an invalid character in title field?
Did you try on more than one movie?
You can also set a breakpoint by clicking in the margin of the script editor, and advance line by line, checking contents of each variable to see if it is correct.
You can find more info on script in the help file, in "technical info" section.
But some of the functions used are are standard Delphi functions so I did not include these in the help file.