Go Back   RetouchPRO > Tools > Software > Photoshop Scripting
Register Blogs FAQ Site Nav Search Today's Posts Mark Forums Read

Photoshop Scripting Learning and sharing for all platforms

I need a Script like a mail merge!

Thread Tools
Old 02-16-2005, 09:25 AM
clickin clickin is offline
Junior Member
Join Date: Feb 2005
Posts: 4
Lightbulb I need a Script like a mail merge!

I need a script like a mail merge! I want to rename my files to the names of the students. I have a excel spread sheet with all the names and the file names. I need a script to rename the camera file name to the person's name.jpg. I hope that was clear. Does anyone have any ideas? I am new to scripts. I do understand that this would be a VB script to be able to open up an excel document. If anyone has ideas for me on were to start let me know. thanks
Reply With Quote top
Old 02-16-2005, 10:31 AM
byRo's Avatar
byRo byRo is offline
Senior Member
Join Date: May 2004
Location: Goianésia, Brazil
Posts: 1,609
Hi there clickin, welcome to RetouchPRO.

It's a shame that I won't have time to try this for a couple of days, but what you want is pretty easy to do.
Just a note though. Although VB isn't off bounds by any means, most people are more used to writing Photoshop scripts in javascript (JS). In practice the difference would be that you'd just have to export the excel data to a text file so JS can get a hold of it.
If nobody cracks this in the mean time, I'll have a go this weekend.

Reply With Quote top
Old 02-16-2005, 10:40 AM
MBChamberlain's Avatar
MBChamberlain MBChamberlain is offline
Senior Member
Join Date: Nov 2004
Location: Knoxville Tennessee
Posts: 281
You could just convert your excel file into a batch file to replace...

1) You need a program that allows regular expressions...if you don't have one there is a really good free one called vim (you can download it here)
2) Export your excel file as a delimeted file using a character not in your file (like the semicolon)
3) Open it in the program with regular expression replacement
4) Perform a regular expression find replace to create the commands to rename you files
5) Change the file extension to "bat"
6) Run the script

If you are using vim, you would navigate to the folder you saved your file and type:

vim <filename>

vim has no gui, so you have to type all the commands...

if your format is <filename>;<Name> type the following string pattern:

: the colon gets you a prompt
%s/\([^;]*\);\([^;]*\)/rename "\1" "\2.jpg"/
where jpg is your file type

\( \) denotes it as a reference
[^;] says to take any character but a ";"
* means accept any number of the previous set, meaning any group of characters that do not contain a ";"
the \1 and \2 refer to your previous references.

this will change the line:

file.jpg;Doe, John
rename "file.jpg" "Doe, John.jpg"

if you let me know how the file is layed out I can get you the exact search string.

then finally you would type ":wq" to save and close the file.

Regular expressions are very powerful, and it really will save you a lot of time in a lot of tasks if you get to know them well.

Hope that helps,

Reply With Quote top
Old 02-16-2005, 10:50 AM
clickin clickin is offline
Junior Member
Join Date: Feb 2005
Posts: 4
mail merge script

Java or VB it doesn't matter. I was hoping to write it in Java ... but thought that the file thing would make it easier in VB. If you have a chance, I would appreciate any help.

Reply With Quote top
Old 02-17-2005, 06:23 PM
xbytor xbytor is offline
Join Date: Aug 2004
Posts: 35
The JS Way

1) Export the file as a csv (comma separated values). This is done manually from Excel.
2) Write a JS script that reads the csv a line at a time.
3) Break each line into its component parts. JS does actually have very good regular expression support, but a simple String.split(",") call may be sufficient.
4) Use the JS File APIs to rename, copy, or do whatever it is you need to do with the files.

There are other ways of doing this, but you have PS which means you have JS available. Personally, this is the kind of problem that I would use perl or bash to solve.

Reply With Quote top

  RetouchPRO > Tools > Software > Photoshop Scripting

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help needed to merge a face on to a picture! jamesatkins Image Help 10 05-01-2007 02:16 PM
merge photos together kewl_head Photo Compositing 5 09-09-2005 07:12 PM
how does PS merge layers? mediatevictoria Photo Compositing 9 05-28-2004 09:46 AM
Can't merge layers when creating mask BrianF Hidden Power Support 1 06-18-2003 05:59 PM
Mail Washer Ed_L Software 3 02-05-2003 05:48 AM

All times are GMT -6. The time now is 08:22 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
Copyright © 2016 Doug Nelson. All Rights Reserved