Parsing a File Name into A Timestamp and Applying it as Metadata
Hello,<br /><br />I am working on a lo-fi photographic documentation project, and the camera I am using does not record EXIF information. The extent of the metadata it provides is in the naming convention which is in the format of "DD-MM-YY_HHMM.jpg". What I am trying to do is create a script to take a selection of images and parse the filename into a timestamp to apply it into the IPTC and EXIF properties and also add in the EXIF Make, Model, et al.<br /><br />The following code I am in the process of working on but have hit a block. After the line: "var md = file.metadata;" nothing seems to happen. I have placed an arbitrary "Window.alert("Hi")" in just to see if it would get executed and it did not. Can anyone explain why this is and why I get no error response if something is in fact wrong?<br /><br /> #target "bridge" <br /> <br /> normalize = new MenuElement( "command", "Normalize Motorola v220 Images", "at the end of Tools");<br /><br /> normalize.onSelect = function() {<br /> <br /> // Get The Selected Images<br /> var images = app.document.selections;<br /><br /> for (i=0; i<images.length; i++) {<br /> <br /> // Declare File Variable<br /> var file = images[i];<br /> <br /> if (images[i].mimeType == "image/jpeg") {<br /> // Parse filename into date<br /> var fn = file.name;<br /> var timestamp = "20"+fn.substr(6,2)+"-"+fn.substr(3,2)+"-"+fn.substr(0,2)+"T"+fn.substr(9,2)+":"+fn.subst r(11,2)+":00";<br /><br /> // Get Metadata<br /> var md = file.metadata;<br /> <br /> // Apply Date to EXIF Metadata<br /> md.namespace = "http://ns.adobe.com/exif/1.0/";<br /> md.DateTime = timestamp;<br /> md.DateTimeOriginal = timestamp;<br /> md.DateTimeDigitized = timestamp;<br /> <br /> // Apply Date to IPTC Core<br /> md.namespace = "http://ns.adobe.com/photoshop/1.0/";<br /> md.DateCreated = timestamp.substr(0,10);<br /> <br /> // Apply Motorola v220 Related Metadata<br /> md.namespace = "http://ns.adobe.com/tiff/1.0/";<br /> md.Make = "Motorola";<br /> md.Model = "Motorola v220";<br /> <br /> // Apply User Specific Data<br /> <br /> // Rename file<br /> <br /> } else {<br /> <br /> // Give an Alert that the Image isn't a JPEG<br /> Window.alert(file.name+" isn't a JPEG");<br /> <br /> };<br /> <br /> file.refresh();<br /> <br /> };<br /> };<br /><br />I would also like to rename the files to the timestamp sans the colons but that will come after.<br /><br />Help.
That didnt seem to work, the same full filename (minus the extension) still prints. Here is more of the script. I tried to attach the whole thing but it wouldnt upload.
var originalRulerUnits = preferences.rulerUnits;
preferences.rulerUnits = Units.PERCENT;
try
var docRef = activeDocument;
// Create a text layer at the front
var myLayerRef = docRef.artLayers.add();
myLayerRef.kind = LayerKind.TEXT;
myLayerRef.name = "Filename";
var myTextRef = myLayerRef.textItem;
//Set your parameters below this line
//If you wish to show the file extension, change the n to y in the line below, if not use n.
var ShowExtension = "n";
// Insert any text to appear before the filename, such as your name and copyright info between the quotes.
//If you do not want extra text, delete between the quotes (but leave the quotes in).
var TextBefore = "";
// Insert any text to appear after the filename between the quotes.
//If you do not want extra text, delete between the quotes (but leave the quotes in).
var TextAfter = "";
// Set font size in Points
myTextRef.size = 24;
//Set font - use GetFontName.js to get exact name
//myTextRef.font = "TimesNewRomanPSMT";
myTextRef.font = "Arial";
//Set text colour in RGB values
var newColor = new SolidColor();
newColor.rgb.red = 255;
newColor.rgb.green = 255;
newColor.rgb.blue = 255;
myTextRef.color = newColor;
// Set the position of the text - percentages from left first, then from top.
myTextRef.position = new Array( 2 , 99);
// Set the Blend Mode of the Text Layer. The name must be in CAPITALS - ie change NORMAL to DIFFERENCE.
myLayerRef.blendMode = BlendMode.NORMAL;
// select opacity in percentage
myLayerRef.opacity = 100;
// The following code strips the extension and writes tha text layer. fname = file name only
di=(docRef.name).indexOf(".");
fname = (docRef.name).substr(0, di);
//use extension if set
if ( ShowExtension == "y" )
I really appreciate the help.
Similar Messages
-
Idoc to file with file name as ABCD timestamp and count
Hi,
Greetings!
I have an requirement like iDoc to File and the output file name should be ABCDYYMMDDXX (e.g ABCD14091701) in PI 7.1
where,
Default = ABCD
YY = year
MM = month
DD = date
XX = sequence no. on the same day; e.g. first batch on same day = 01, second batch on the dame day = 02
I tried checking many blogs but its not meeting this requirement.
Kindly please help me out in completing this interface.
Regards,
VinothHi Vinoth,
Below is the code. Use it in-conjunction with your dynamic config code.
String inputFile = "D:\\Receiver"; //This is your target receiver folder
String dateStr = DateFormat.getDateInstance().format(new Date());
dateStr = dateStr.substring(0, 2)+ dateStr.substring(3, 5)+ dateStr.substring(8,10);
final String fileNamePattern = "DEFAULT"+dateStr;
File file = new File(inputFile);
File[] listFiles = file.listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
if(name.contains(fileNamePattern))
return true;
return false;
//System.out.println("Number of files in the directory "+inputFile+" : Next Counter"+ (listFiles.length+1));
int counter = listFiles.length+1;
String fileName = "";
if(counter < 10)
fileName = fileNamePattern+0+counter;
else
fileName = fileNamePattern+counter;
System.out.println("Name of the file will be:"+fileName);
Hope it helps!
Best Regards,
Anand Patil -
Load Source File Names into Recordset Object
Hi,
I have a folder with abc.txt, xyz.txt, pqr.txt etc files.
My requirement is to load all the file names into a Record Set which I need to use in data flow. I think I need to use For each loop container with Enumerator as 'Foreach File Enumerator' and in the variable mappings I have added a variable name
to get the file name. But I have stuck how to add these file names to a Record Set target. Please help me.
Thanks.Hi Amaya14,
Go these this link Click Here
Thanks -
Script to insert file name into keywords field of same file
Hello,
search a solution, a Script or another, which writes the file name into keywords field of same file (Metadata: Description/Keywords) in "photoshop", "bridge" or better in "Lightroom" .
I found this topic from Mike Hale http://www.ps-scripts.com/bb/viewtopic.php?t=1330
It's possible this script to change this in such a way that it does this:
"script to insert file name into keywords field of same file"
Thanks and best greetings
WolfgangThis works in CS2:-
#target bridge
if( BridgeTalk.appName == "bridge" ) {
nameDescription = MenuElement.create("command", "AddName to Description", "at the beginning of Thumbnail");
nameDescription .onSelect = function () {
nameToDescription();
function nameToDescription(){
var items = app.document.selections;
for (var i = 0; i < items.length; ++i) {
var item = items[i];
var m = item.synchronousMetadata;
filenameToDesc(m, item.name.slice(0,-4));
function filenameToDesc(metadata, Description) {
var strTmpl = "name2Desc";
var strUser = Folder.userData.absoluteURI;
var filTmpl = new File(strUser + "/Adobe/XMP/Metadata Templates/" + strTmpl + ".xmp");
var fResult = false;
try
{ if (filTmpl.exists)
filTmpl.remove();
fResult = filTmpl.open("w");
if (fResult) {
filTmpl.writeln("<x:xmpmeta xmlns:x=\"adobe:ns:meta/\" x:xmptk=\"3.1.2-113\">");
filTmpl.writeln(" <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">");
filTmpl.writeln(" <rdf:Description rdf:about=\"\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">");
filTmpl.writeln("<dc:description>");
filTmpl.writeln("<rdf:Alt>");
filTmpl.writeln("<rdf:li xml:lang=\"x-default\">"+Description+"</rdf:li>");
filTmpl.writeln("</rdf:Alt>");
filTmpl.writeln("</dc:description>");
filTmpl.writeln(" </rdf:Description>");
filTmpl.writeln(" </rdf:RDF>");
filTmpl.writeln("</x:xmpmeta>");
fResult = filTmpl.close();
metadata.applyMetadataTemplate(strTmpl, "replace");
filTmpl.remove();
catch(e)
{ fResult = false; }
return fResult; -
Is there a way to display the forms file name, into a text field?
Example: The form's file name is "MyForm.1.01.pdf"
I would like to display "MyForm.1.01" in a text field on the form.
If my form is saved and goes up a revision to say "MyForm.1.02"
"MyForm.1.02" is then displayed in the text field.
I was thinking, this could be on the pre open event, so that when the form is saved, it would display the new revision when the form is next opened?
Thanks in advance.Hi,
The following will get the file name:
this.rawValue = event.target.documentFileName;
I would put this in the docReady event, as this event fires only once, when the form opens.
There is a sample here: https://acrobat.com/#d=ZnxO-dlXXFDS0GvYcQk2NQ
Hope that helps,
Niall
Assure Dynamics -
Linux file name into ODI variable
Hello All,
I have a situation where we have files in one directory in linux ,I want to import the file name into a ODI variable.
Ex : A_B_C_2014_01_20.zip (inside this zip file are the flat files with data) is the file name in /u02/source_files location , i want this into a ODI variable and once the data loading is complete ,i want to log it saying
A_B_C_2014_01_20.zip complete
A_B_C_2014_01_21.zip complete.
So my other shell script will look for the complete flag and copy the next file into the ODI pick up location.In this case I need to pick up A_B_C_2014_01_22.zip and start the data loading.
How do i implement this functionality in ODI. Please let me know.Issue was due to a syntax error. Case closed.
Thanks!
-OS -
can not transfer date from one hard drive to another, I keep getting an error because I have two of the same file names and one file name is in caps and I cant change the file name. My original external has an error and needs to be reformatted but I dont want to lose this informations its my entire Itunes library.
Sounds like the source drive is formatted as case sensitive and the destination drive is not. The preferred format for OS X is case insensitive unless there is a compelling reason to go case sensitive.
Why can't you change the filename? Is it because the source drive is having problems? If so is this happening with only one or two or a few files? If so the best thing would be to copy those over individually and then rename them on the destination drive.
If it is more then you can do manually and you can't change the name on the source you will have to reformat the destination as case sensitive.
Btw this group is for discussion of the Support Communities itself, you;d do better posting to Lion group. I'll see if a host will move it. -
Get the file name into a Odi variable
Hi,
I need to get the file name into odi variable like ..A/ETC/file.txt
For eg.the filename file.txt should get store in a variable.
Then i want to compare the file name stored in the variable with some other value.
Please suggest.
Thanks.in package,
declare the variable, then evaluate it with another variable, generally using # syntax
if the variable is date type, suggest to use : syntax, because # will treat the variable value as text value
in loadplan
use case when syntax, -
Sharepoint Workflow : how to get document full path + file name into variable?
Hi,
Anybody knows how to get document full path + file name into a variable in Sharepoint 2010 workflow?
Example http://sp1:80/InvoiceQueue/Shared Documents/123.pdf
I am using List Workflow which links to a document library.Hi SAMSUNG,
According to your description, my understanding is that you want to get the full path of a document in a list workflow.
You can set the variable to the Enconded Absolute URL of the document. The screenshot is my testing. In my testing (in the red area), when the title of a document was equal to the tile of the current item, set a variable to the Enconded Absolute URL of the
document. I used ‘Log to history list’ to check the value of the variable in Workflow History .
I hope this helps.
Thanks,
Wendy
Wendy Li
TechNet Community Support -
How to insert the file name to the start and the end of a SQL file by a powershell script
I just began to learn powershell script and I have a problem that I cannot figure out. I have a lot of .sql files. I need to insert its file name to the beginning of the file (After USE statement) and the end of the file (before the last END statement). Is
there anybody knowing how to do this?
Thanks so much
RegardsActually, I want to add a insert SQL statement to the beginning of the file and the end of the file. Only the file name is a variable and different among
different files. All the other sql statements are the same and can be hard coded. Hopefully it helps –
The problem I think is that I want to add the same thing (except the file name) to hundreds of sql files and only the file name is different. I do not want
to add it manually and want to use a script to add it – -
Is there a way to create a master doc page that automatically imports the current document file name into a desired location?
Perhaps a text variable of the filename on the master? Look this up in the help.
Mike -
Method for quickly putting file names into IPTC core description?
I would like to put the file names into the IPTC core description. The files are all named differently .Is there a way to batch this or any other way of automatically including it so that I don't have to do each file separately? Or perhaps there is a plug in?
I am using PS5/ bridge on a mac.You only need a script… not a plug-in to do this. Search the bridge scripting forum as Im sure Paul has posted several variations of scripts that do this…
-
What are shortest file names for outlook express and PSE11 to import photos pls
what are shortest file names for outlook express and PSE11 to import photos pls
Hi, Troubled. The size of the file name is pretty much irrelevant here to PSE, but to answer your question directly, you will be able to import a file that has only a single character as its file name (plus the file name needs to have the required extension, such as .jpg)
-
How to copy the photo with file name at window 7 and search specific one in iphone 4s?
How to copy the photo with file name at window 7 and search specific one in iphone 4s?
Clendenen02 wrote:
2) It would be equally helpful if there was something that would take the name of the picture file and spotlight comment, copy and paste it to a movie file's comments with the same name but obviously has different extention. For an example
In a Pictures folder
Name: Dark Knight, The.jpeg Comment: (2008) Genre: Action... <- copy comment
In a Movie Folder
Name: Dark Knight, The.m4v Comment: <- paste
and do this for all 700 files
This Bash script will do it.
Edit "PicDir" and "MovDir" to the location of your Folders
(Note: The comment is written to the m4v file using xattr, so the Spotlight comment field appears blank in Finder, but the comment metadata is still indexed by Spotlight (If you add a Spotlight comment from Finder, it is stored both as an extended attribute and in a .DS_Store file)
#!/bin/bash
PicDir=$HOME/Desktop/Pictures
MovDir=$HOME/Desktop/Movies
for f in $PicDir/*
do
if [ ! -d "$f" -a "${f##*.}" == "jpeg" ]; then
comment=$(mdls -raw -name kMDItemFinderComment "$f")
if [[ $comment != "(null)" ]]; then
picname=${f##*/}
movname=${picname%.*}.m4v
if [ -e "$MovDir"/$movname ]; then
xattr -w com.apple.metadata:kMDItemFinderComment "\"$comment\"" "$MovDir"/$movname
fi
fi
fi
done -
Parsing a file name and printing a portion to an image
Ive got a script writen for me that reads the file name of the image, creates a new layer , prints it ti the bottom of the image. I was wondering if anyone knew if there is a way to parse only a portion of the file name out and print that to the screen. Below is the relevant part f the code (I think) that selects the text to be printed on the new layer
var myLayerRef = docRef.artLayers.add();
myLayerRef.kind = LayerKind.TEXT;
myLayerRef.name = "Filename";
var myTextRef = myLayerRef.textItem;
if the file name of the image is ; 30090416 0056 , I want to use only the 0056 portion, as the code is written above the whole file name save the extension is written to the image.
Thoughts?????That didnt seem to work, the same full filename (minus the extension) still prints. Here is more of the script. I tried to attach the whole thing but it wouldnt upload.
var originalRulerUnits = preferences.rulerUnits;
preferences.rulerUnits = Units.PERCENT;
try
var docRef = activeDocument;
// Create a text layer at the front
var myLayerRef = docRef.artLayers.add();
myLayerRef.kind = LayerKind.TEXT;
myLayerRef.name = "Filename";
var myTextRef = myLayerRef.textItem;
//Set your parameters below this line
//If you wish to show the file extension, change the n to y in the line below, if not use n.
var ShowExtension = "n";
// Insert any text to appear before the filename, such as your name and copyright info between the quotes.
//If you do not want extra text, delete between the quotes (but leave the quotes in).
var TextBefore = "";
// Insert any text to appear after the filename between the quotes.
//If you do not want extra text, delete between the quotes (but leave the quotes in).
var TextAfter = "";
// Set font size in Points
myTextRef.size = 24;
//Set font - use GetFontName.js to get exact name
//myTextRef.font = "TimesNewRomanPSMT";
myTextRef.font = "Arial";
//Set text colour in RGB values
var newColor = new SolidColor();
newColor.rgb.red = 255;
newColor.rgb.green = 255;
newColor.rgb.blue = 255;
myTextRef.color = newColor;
// Set the position of the text - percentages from left first, then from top.
myTextRef.position = new Array( 2 , 99);
// Set the Blend Mode of the Text Layer. The name must be in CAPITALS - ie change NORMAL to DIFFERENCE.
myLayerRef.blendMode = BlendMode.NORMAL;
// select opacity in percentage
myLayerRef.opacity = 100;
// The following code strips the extension and writes tha text layer. fname = file name only
di=(docRef.name).indexOf(".");
fname = (docRef.name).substr(0, di);
//use extension if set
if ( ShowExtension == "y" )
I really appreciate the help.
Maybe you are looking for
-
HP Laserjet 4100 on ExtendNet XS print server
Morning. I've connected an HP Laserjet 4100 via parallel cable with an ExtendNet SX ESI6004436 print server. The print server is connectes via ethernet cable with an Airport Express. For Windows there is a software ESI-Tools to handle and install the
-
Is there any way to edit HD video on a Macbook 2GHZ Intel core 2 duo without it being RIDICULOUSLY slow? I can't even play back a track in the sequence without having to render first, and if i edit that same track, i have to render again for playback
-
Dock needs a lot of memory?
Couldn't resist showing a screen dump of memory allocations for Dock: http://netserv.se/netserv/dock.png It's swedish, but third line is "shared memory size" -- 16777216 TB -- that's pretty much on a PowerBook 12" !
-
Uploading Time data to HR Clusters B1 and B2
Hi All, My agenda is download Time data ( Hr cluster B1 and B2 ) from One SAP System ( 4.7 ) using Macr RP-IMP-C1-B1, RP-IMP-C2-B2 and upload to a ECC 6.0 SAP System using Macro RP-EXP-C1-B1, RP-EXp-C2-B2. Though uploading can be achieved using repor
-
HT201263 touch is not responding
My ipod 3rd generation touch is not responding. I cant turn it off to turn it back on