How to use contents of a field in filenames
-
- Posts: 68
- Joined: 2015-06-30 22:25:21
How to use contents of a field in filenames
I have about 6500 entries in AMC. They're all films and all have the year the film was released in the field named 'Year'. What I would like to do is include that date into the filename.
So, 'Batteries not included.mp4' in the original title, would become 'Batteries not included (1987).mp4'.
I have managed to name all the files on the disks in this way, exporting the names and year fields and then using Python to change the file names on disk. But I would love to be able to change the film title in the program too.
Is it possible?
So, 'Batteries not included.mp4' in the original title, would become 'Batteries not included (1987).mp4'.
I have managed to name all the files on the disks in this way, exporting the names and year fields and then using Python to change the file names on disk. But I would love to be able to change the film title in the program too.
Is it possible?
Re: How to use contents of a field in filenames
It should be easy to do with the script engine of AMC:
Untested, if it does not work it should be something close to that.
Assuming the file path is in the appropriate field, otherwise change the constant "fieldFilePath" to something else.
For more info about functions in the script engine, see in Help -> Technical info -> Script
Code: Select all
program AppendYear;
var
name, ext: string;
begin
ext := ExtractFileExt(GetField(fieldFilePath));
name := ChangeFileExt(GetField(fieldFilePath), '') + ' (' + GetField(fieldYear) + ')' + ext;
SetField(fieldFilePath, name);
end.
Assuming the file path is in the appropriate field, otherwise change the constant "fieldFilePath" to something else.
For more info about functions in the script engine, see in Help -> Technical info -> Script
-
- Posts: 68
- Joined: 2015-06-30 22:25:21
Re: How to use contents of a field in filenames
That means absolutely nothing to me lol but thanks, I shall check in help and see if I can figure something out.
-
- Posts: 68
- Joined: 2015-06-30 22:25:21
Re: How to use contents of a field in filenames
I am really struggling here. Is the script editor the one you access from the folder full of internet scripts? I tried making a new file and input the details you gave me but no matter how I juggle it it just keeps saying there is a script editor.
Is there any way I can access a simple text list of all film entries in the database? Clearly the scripting isn't going to work but if I can access the filenames I could do it from there?
Is there any way I can access a simple text list of all film entries in the database? Clearly the scripting isn't going to work but if I can access the filenames I could do it from there?
-
- Posts: 745
- Joined: 2007-04-28 05:46:43
- Location: Italy
Re: How to use contents of a field in filenames
... sorry... do you want to add year in file names (in your folder) or will you add year in field "file path" of your catalog?
Re: How to use contents of a field in filenames
What is the problem with the script exactly?
You to go Tools -> Scripting, click the "Editor" tab and then the "new" icon (white paper sheet) and paste the script there.
You to go Tools -> Scripting, click the "Editor" tab and then the "new" icon (white paper sheet) and paste the script there.
-
- Posts: 68
- Joined: 2015-06-30 22:25:21
Re: How to use contents of a field in filenames
Yeah so in the 'Original Title' field the films name appears when you import. The date appears in the 'date' field. I would love the film title to be in the format 'title and year'. So for example, "Great film (2024)". But I can't figure out how to get the year to appear in parentheses after the title. That's one goal.fulvio53s03 wrote: ↑2024-09-16 16:29:04 ... sorry... do you want to add year in file names (in your folder) or will you add year in field "file path" of your catalog?
But also I want to name the files on disk in the same format as they are in AMC. Currently it has taken me weeks to fudge together a working script to achieve this but it means exporting Title and Year from AMC, then taking the Tree list from the disk holding the films and add that list to the csv file produced by AMC. So now I have 3 columns in the csv: the disk generated list of files, the amc generated list of titles, and the years of all titles. I then have to correct all the mistakes where films don't line up because the order they are listed is different in Windows, as it is in AMC. Once I get them all lined up properly, then I now have some scripts that can compare the titles to those on disk, and insert the date like this (2024) before the file extension. So that part is easy. The difficult and time consuming part is getting the two lists to match.
-
- Posts: 68
- Joined: 2015-06-30 22:25:21
-
- Posts: 745
- Joined: 2007-04-28 05:46:43
- Location: Italy
Re: How to use contents of a field in filenames
First of all, save your AMC archive using a new name.boristhecat wrote: ↑2024-09-24 19:31:12
Yeah so in the 'Original Title' field the films name appears when you import. The date appears in the 'date' field. I would love the film title to be in the format 'title and year'. So for example, "Great film (2024)". But I can't figure out how to get the year to appear in parentheses after the title. That's one goal....
After this create a new script: Add_date
Code: Select all
(***************************************************
Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/
[Infos]
Authors=fulvio53s03
Title=ADDdate
Description=aggiunge data al titolo originale
Site=
Version=0.1
Requires=3.5
Comments=
License=GPL
GetInfo=1
RequiresMovies=1
[Options]
[Parameters]
***************************************************)
program ADDdate;
uses
StringUtils7552;
var
title_orig, year_orig: string;
begin
title_orig := getfield(fieldoriginaltitle);
year_orig := getfield(fieldyear);
title_orig := title_orig + ' (' + year_orig + ')';
SetField(fieldoriginalTitle, title_orig);
end.
Re: How to use contents of a field in filenames
That line should be the first line. Maybe I should have said that you can replace the contents by the one I providedboristhecat wrote: ↑2024-09-24 19:39:37 All it ever says to me is "Error in statement at line 2" which is 'program AppendYear;'
-
- Posts: 68
- Joined: 2015-06-30 22:25:21
Re: How to use contents of a field in filenames
Simple and perfect. Than you.fulvio53s03 wrote: ↑2024-09-25 05:30:16First of all, save your AMC archive using a new name.boristhecat wrote: ↑2024-09-24 19:31:12
Yeah so in the 'Original Title' field the films name appears when you import. The date appears in the 'date' field. I would love the film title to be in the format 'title and year'. So for example, "Great film (2024)". But I can't figure out how to get the year to appear in parentheses after the title. That's one goal....
After this create a new script: Add_dateExecute it and take a look to your new archive. If it is OK, we have resolved the first step of our work.Code: Select all
(*************************************************** Ant Movie Catalog importation script www.antp.be/software/moviecatalog/ [Infos] Authors=fulvio53s03 Title=ADDdate Description=aggiunge data al titolo originale Site= Version=0.1 Requires=3.5 Comments= License=GPL GetInfo=1 RequiresMovies=1 [Options] [Parameters] ***************************************************) program ADDdate; uses StringUtils7552; var title_orig, year_orig: string; begin title_orig := getfield(fieldoriginaltitle); year_orig := getfield(fieldyear); title_orig := title_orig + ' (' + year_orig + ')'; SetField(fieldoriginalTitle, title_orig); end.
One small thing, it adds a date to a title even if that title already has the date added, which many hundreds of my files do. So I did a script to delete any date in the title field, then used your script to add the date in. I tried to make one that would detect a date and ignore that field and add the date to ones that did not have one. Sadly for some reason that didn't work buy hey ho, I got what I wanted in the end.
So here's another task. I am not going to see if I can do the same thing with the JPG's in the catalog. Wish me luck!
-
- Posts: 745
- Joined: 2007-04-28 05:46:43
- Location: Italy
Re: How to use contents of a field in filenames
Your catalog is saved as xml? Pictures are in a separate folder?
please extract some titles from your catalog, save them in a next catalog and send it to me (with related images), so that I can well understand and resolve your questions.
please extract some titles from your catalog, save them in a next catalog and send it to me (with related images), so that I can well understand and resolve your questions.
-
- Posts: 68
- Joined: 2015-06-30 22:25:21
Re: How to use contents of a field in filenames
My catalog is just saved as catalog? All the images are in there as JPG's. The catalog database also resides in the catalog folder. What I am going to try is to get the image corresponding to each entry, is named in the exact same format as the movie title in the database. ([title][date]). There's no purpose to this other than to be organised. I've got a copy of my whole program and have been testing on it and so far (touch wood) the title renaming has worked perfectly.fulvio53s03 wrote: ↑2024-09-28 13:11:34 Your catalog is saved as xml? Pictures are in a separate folder?
please extract some titles from your catalog, save them in a next catalog and send it to me (with related images), so that I can well understand and resolve your questions.
-
- Posts: 745
- Joined: 2007-04-28 05:46:43
- Location: Italy
Re: How to use contents of a field in filenames
Very well, your problem seems to be resolved.
Will you tell me if your catalog is a file "xyz.amc" and images are contained within it?
Where did you changed the .jpg name? in a field of the catalog? in folder? in both of them?
I'm really interested, it cold be useful to me to know your work's final steps.
-
- Posts: 68
- Joined: 2015-06-30 22:25:21
Re: How to use contents of a field in filenames
It is indeed a file called movies.amc. It resides in the catalog folder. The images all reside in the catalog folder too.fulvio53s03 wrote: ↑2024-09-28 13:50:21Very well, your problem seems to be resolved.
Will you tell me if your catalog is a file "xyz.amc" and images are contained within it?
Where did you changed the .jpg name? in a field of the catalog? in folder? in both of them?
I'm really interested, it cold be useful to me to know your work's final steps.
So far the only way I have to change the .jpg's name is through AMC itself, or manually going into the folder and changing it in windows. I never do it in windows, I do it through amc while it's open. However as there's thousands of entries I wanted a script that would read the date field of each movie, and append the date to the filename of each corresponding jpg file.
I haven't quite got that figured out as yet, I think I will have to export the date field, and use a python script to match the .csv file full of dates to the list of images in the folder, and overwrite the names.