A script for adding the current date to file name?

I am working in Indesign CS3. I frequently save file as PDFs into a designated folder. I was hoping for help in writing a script that would apply the current date to the end of the file name, when saved into this folder. Some days, I save the same file several times, into this folder. I was also hoping there was a way to add a date and version, for example "filename_2.25.11(1).pdf" Is this possible? Can someone help me?

ok, I ended up with this test routine:
on adding folder items to this_folder after receiving added_items
tell application "Finder"
repeat with this in added_items
my checkifopened(this)
display dialog (name of this) as text
end repeat
end tell
end adding folder items to
on checkifopened(this)
set a to POSIX path of (this as alias)
repeat until 1 = 0
## don't like that one because it relies on an error msg ... so
(** try
set b to do shell script "lsof | grep " & quoted form of a
on error
exit repeat
end try**)
##so I use this one
set b to do shell script "lsof"
if b does not contain a then
exit repeat
else
say "still opened"
end if
end repeat
end checkifopened
this is a folder action that tests if the added file is still opened by an application... there is no delay between each test-loop since lsof takes some time to execute...
And after adding a timeout (just in case) to this function the final script looks like this:
on adding folder items to thefolder after receiving added_items
tell application "Finder"
set folderkind to kind of thefolder
set myfiles to every item of thefolder whose name does not contain "#" and kind is not folderkind
repeat with myfile in myfiles
set myfile_datestring to my get_datestring(creation date of myfile)
set myfilename to name of myfile
if (count of every character of myfilename) > 4 and (character -4 of myfilename) as text is "." then
set filestatus to my checkifopened(myfile, 60)
if filestatus = false then
display dialog "timeout on folder action"
else
set tmp to ((characters 1 through -5 of myfilename) & "#" & myfile_datestring & (characters -4 through -1 of myfilename)) as text
set myfilename to my checknamewith_pdfsuffix(tmp, thefolder, false)
set name of myfile to myfilename
end if
end if
end repeat
end tell
end adding folder items to
on get_datestring(mydate)
return year of mydate & "-" & (characters -2 through -1 of (("0" & (month of mydate as integer)) as text)) & "-" & (characters -2 through -1 of (("0" & (day of mydate as integer)) as text)) as text
end get_datestring
on checknamewith_pdfsuffix(n, D, looped)
--check if filename exists in D
-- so if "A File.pdf" exists it names it "A File 1.pdf","A File 2.pdf",...
#n = string of the filename
#D = file reference to the directory to check
#looped = boolean used for recursive loop...
tell application "Finder"
set thefiles to name of every item of (D as alias)
end tell
if thefiles contains n then
if looped = false then
set n to ((characters 1 through -5 of n) & "(1)" & (characters -4 through -1 of n)) as text
my checknamewith_pdfsuffix(n, D, true)
else
set tmp to (last word of ((characters 1 through -5 of n) as text) as integer)
set tmpcount to (count of characters of (tmp as text)) + 5
set tmp to tmp + 1
set n to ((characters 1 through (-1 * tmpcount) of n) & "(" & tmp & ")" & (characters -4 through -1 of n)) as text
my checknamewith_pdfsuffix(n, D, true)
end if
else
return n
end if
end checknamewith_pdfsuffix
on checkifopened(this, mytimeout)
## this file reference
## timeout in seconds
set a to POSIX path of (this as alias)
set startdate to current date
repeat until 1 = 0
## don't like that one because it relies on an error msg ... so
(** try
set b to do shell script "lsof | grep " & quoted form of a
on error
exit repeat
end try**)
##so I use this one
set b to do shell script "lsof"
if b does not contain a then
return true
else if ((current date) - startdate) > mytimeout then
return false
else
##say "still opened"
end if
end repeat
end checkifopened
to use this save this script in /Library/Scripts/Folder Action Scripts
and add this as a folder action to your folder...
The script processes all files inside that folder each time a new files is added...

Similar Messages

  • Poweshell script for adding the computer object in to SCOM 2012 group.

    Hi Team,
    Is there any way to add the computer object ( csv file) to SCOM 2012 manually created  group.

    Hi,
    In addition, hope the links below be helpful for you:
    Creating and Updating Groups
    http://blogs.msdn.com/b/jakuboleksy/archive/2006/11/15/creating-and-updating-groups.aspx
    Programmatically Creating Groups
    http://blogs.technet.com/b/brianwren/archive/2008/11/18/programmatically-creating-groups.aspx
    Modifying Explicit Group Membership in SCOM 2012 with PowerShell
    http://blogs.msdn.com/b/rslaten/archive/2013/06/27/modifying-explicit-group-membership-in-scom-2012-with-powershell.aspx
    Regards,
    Yan Li
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • Current Date in file name

    Hi gurus,
    I export daily a report to csv using RSCRM_BAPI ... I need to the put the date of the extraction in the file name (export_csv_120506.csv) ... It's possible ?
    export_csv_ + "sysdate" ... something like that ?
    Thanks in advance for your help,
    Alex

    Hi,
    I would suggest you to write an UNIX shell script (if it suits your environment) to rename from whatever existing fileanme to your desired file name.
    Hope this helps.
    Thanks,
    Raj

  • How to put current date in File name while saving PDF file.

    Hi expert,
    A report is scheduled for broadcasting  in PDF format . User wants it should have current date in its file name.
    Now system generated file name is Z_XXX_YYY_0000.pdf , but it should have Z_XXX_YYY_10012012.pdf or in any date format.
    Regards,
    Anand Mehrotra.

    First, how to best change the name of the folder. In Library view, there is a Folders panel within the lest hand side panel. If you select the folder and bring up the context menu, you can select the rename option to change the name/date of the folder. Lightroom will also cause the name to be changed on the HDD so both Lightroom as well as the OS will know about the change. This is the simplest way to handle folder name changes.
    Renaming the photos contained within the folder is a bit trickier. I have tried the Lightroom batch rename function, which should work by the way, I encountered some issues in which Lightroom wanted to substitute a sequence number, starting at 0001 rather than use the starting number I wanted to use. This was in Lightroom 4.x and I ended up having to manually rename files. To rename the files within the folder, select the folder to display the grid view of the images within that folder. Next, select all of the photos you want to rename and then select Library/Rename Photos (must be in Library mode) or just press the F2 key. This will open a Rename Photo dialog. Use the drop down box to select your naming scheme (or custom, which will open the Filename Template Editor where you can build your own template. From there, just click to confirm your choices and you should be able to rename your files.
    As I said above, I did have trouble with this in V4.x so I suggest only selecting one of the photos and testing it out. If it works, you can select the rest and complete your task. If it doesn't, then you can fix that, try again to get it to work or just manually rename your photos which is what I ended up doing.

  • Used variable substitution to substiture the field 'date' in file name

    Hi gurus
    I have used variable substitution to substiture the field 'date' (dd/MM/yyyy/hh/mm/ss) in the file name so when empty payload (a valid xml ) is generated by Message mapping then the communication channel is failing by showing the following error
    File processing failed with com.sap.aii.adapter.file.configuration.DynamicConfigurationException: Error during
    variable substitution: com.sap.aii.adapter.file.varsubst.VariableDataSourceException: The following variable was not found in the message payload
    : date
    As of now the business is not getting effected as the business scenarion needs only customer master data at the reciever side But when ever there is no custmer master data in the sourse side the message mapping is generating an empty payload and the communication channel is failing ( so it is an internal issue and is there any way which could solve the both (ie the business must not get effected and as well the communication channel must not fail)
    any coments on this will be higly apreciated
    thanks and regards
    sandeep

    Hi Sandeep -
    Yes If you use the Variable substitution from the payload , that perticular field has to be generated in the target structure.
    To handle this You can do the following:
    Sourcefield --->exists -> IfThenElse-->TargetField
    Where     SourceField>exists(node function)-> If
                   SourceField -
    >Then
                   CurrentDate(Date Function)----->Else
    Hope this will help !!
    Regards.
    Jeet.

  • How to get the current Date

    With the following piece of code, I am able to get the current date in bpe forms, but not when I put it in any of the forms logged in using end user(not even in end user menu).
    <Field name='request.submitDate'>
    <Display class='Label'>
    <Property name='value'>
    <invoke name='dateToString' class='com.waveset.util.Util'>
    <ref>java.util.Date</ref>
    </invoke>
    </Property>
    </Display>
    </Field>
    The following error is getting displayed in the end user menu form.
    XPRESS exception:
    Can't call method dateToString on class com.waveset.util.Util ==> java.lang.NullPointerException: -------can anyone please help me out
    or can anyone suggest a way for getting the current date
    Regards
    Gajendra Nagapurkar

    The <ref> tag is used to refer to the value of some variable. The value of the variable java.util.Date in your example is NULL, because it doesn't exist!
    If you remove that argument from your <invoke>, the call resolves to the method com.waveset.util.Util.dateToString() and will return something like "20050810 11:00:21".

  • Print web page to PDF with date as file name

    Hi
    I'm doing environmental monitoring for a construction project and i need to download the 5 day forecast from a particular web site daily. I'd like to automate this to happen at 7 am every day. I've tried record but am having problems.
    Here are the steps i'd like it to take:
    1. Open book mark in Safari
    2. Open print dialog (command p)
    3. Open save to PDF
    4. Select folder in finder
    5. Enter current date as file name
    6. Save pdf file.
    I've tried Get Specified URL and nothing happens. When i record the mouse always misses.
    Help

    Hi... had to put this up for a while as I got busy in my day job. Here's where i'm at
    I can successfully generate a PDF file but it's blank. The other two problems I'm having is that I'd like to name the file with the current date. I can call up the current date using that tool but i can't figure out how to make it the file name whether i print to pdf or use the tool.
    I think there's something i'm missing here.
    Message was edited by: Gary Springs

  • Acrobat 9 - how do you create a dynamic stamp to include the current date (java script)

    I have seen my question multiple places and times but the resolutions provided have not worked for me.
    I am running Acrobat 9 Pro, cannot run X or XI due to the use of ProSystem fx Engagement.
    I want to create what I thought would be a simple stamp. My initials and the current date. i.e. "crm 01/10/13".
    Simple right? I created a PDF of my initials. Now I just need the text field with the proper Java Script to insert the date, correct?
    I have tried opening "Dynamic.pdf" and copying and pasting the text field that includes the Java Script:
    " event.value = (new Date()).toString(); AFDate_FormatEx("h:MM tt, mmm dd, yyyy"); "
    The date does not update, it stays static.
    I have manually entered the Java Script.
    I have edited the Java Script to remove the "Ex".
    I have edited the Java Script to revise the "yyyy" to "yy".
    I have edited the Java Script to remove the " h:MM tt, " trying different formats to get "dd/mm/yy".
    I have selected "Use single-key accelerators to access tools" in Preferences/General.
    I have tried PDF files, PNG files. I have created the image files from Word and Excel.
    I am at my wits' end. Can someone PLEASE assist me to resolve what should be a simple issue (I hope).
    Thank you in advance.

    Thank you for your response.
    Your script works well, but I still have the same issue.  The date is remaining static to the system date when the stamp is created.  My initial idea was to create a pdf of my initials "crm" and then add the text field with the java script for the date behind my initials.  "crm" + (TEXT FIELD with JS).  I wanted 3 stamps, red, blue and green.  The colors correspond to specific processes in our workflow.
    Your script adds my initials as well as the date.
    My machine is running Windows 7.
    My stamps are located:
    C://Documents/Acrobat Stamps/...
    Acrobat templates:
    C://Program Files (x86)/Adobe/Acrobat 9.0/Acrobat/plug_ins/Annotations/Stamps/ENU/...
    I have no problem creating stamps, just a stamp that will use the current system date.  I HATE using the typewriter for my initials and the date.  I guess I can stamp my initials and then type the date...but what is the point?
    Do you have any further thoughts or suggestions?
    Thank you very much.
    crm 01/11/13 

  • Show options for projected amount of time based on the current date?

    I'm wondering if anyone has any ideas on how to go about this, or has done something similar before.
    I would like to be able to have the user see what the current date is, and then based on that, be able to schedule an appointment for say, the next two weeks, given that they can select either a Tuesday or Wednesday. (When they "schedule" an appointment, I would just be sending out that info to a spreadsheet or something.)
    So, if today is Tuesday, 6/10/14, they will then see that they can select either Wednesday, 6/11, or a different Tuesday or Wednesday within the next two weeks. Ideally, they would be able to see all of those possible dates listed out, and click/select one.
    If this isn't possible in Captivate, is there another way to do this, and then embed that within that as a web page or object in Captivate, or run a script, maybe?

    I don't think you'd find a way to do the actual date changes and scheduling through CP - that's far more advanced that it's intended for. If there is a way, it'll take complex Actionscripting (and likely external javascripting).
    BUT if your developers can create a webpage that does this (i.e. .NET or PHP), sure, you could put that on a webserver somewhere then use a 'Web Object' in CP to import that page into an iframe so users can interact.
    CP won't know what the users are doing in the iframe...but with CP you could put instructions on the page too, maybe some general callouts, and follow up with a quiz or so.

  • Script for adding a login item for all accounts in the system

    Hi,
    Thanks for reading this query. I am new to the mac environment. I have developed a java application and created an installer of this application for MAC system.I want to run this application on starting the system. So I have written an apple script for adding this application in login items and this script will run immediately after completing installation process. And the entire process is fine. But the problem is, the application is added to login items of only the user who installed the application. But I want to get available the application in the login list of all accounts created in the system. How can I achieve this? Once more thanks in advance. I am attaching my script below:
    +*tell application "System Events"*+
    +* make login item at end with properties {path:"/Applications/MyApplication.app", hidden:true}*+
    +*end tell*+

    Hi,
    Try to use tables RSOSFIELDMAP, RSDSSEGFD and RSTRAN
    Hope it helps
    bhaskar

  • I have microsoft word for for my Mac book pro. When I open saved letters /documents on word the date automactically changes to the current date. How do I stop this happening? Many Thanks

    I have microsoft word for for my Mac book pro. When I open saved letters /documents on word the date automactically changes to the current date. How do I stop this happening? Many Thanks

    I suggest you post your qeustion on the Microsoft Mac forums as it's their software you're having issues with and that's where the MS experts hang out
    http://answers.microsoft.com/en-us/mac

  • Adding a year to the current date field

    Hello,
    Can any one please help on how to add a year to the current date field.
    e.g 7/19/2011 plus a year = 7/19/2012
    Thanks,
    Han Dao

    If you had a field DateTimeField1 and wanted to display the following year in DateTimeField2, you could do the following in JavaScript;
    var d1 = util.scand("yyyy-mm-dd", DateTimeField1.rawValue);
    if (d1 !== null)
    d1.setFullYear(d1.getFullYear()+1);
    DateTimeField2.rawValue = util.printd("yyyy-mm-dd", d1);
    Good luck
    Bruce

  • How can I make iCal in Lion open to the current date?

    I just updated from Snow Leopard to Lion and have had all of the frustrations with changes to iCal that are well-documented here and elsewhere.  One issue I haven't seen addressed, however, is a new behavior after quitting and re-starting.
    Previously, no matter what month/day/week I was viewing when I quit iCal, it would open the next time to the current (month/day/week).  Now, it opens to whatever date(s) I was last viewing when I quit.
    This is highly annoying - 99% of the time, if I quit iCal while looking at (some date 6 months into the future), that is NOT the date I'm looking for when I re-launch.  It's much more consistent behavior to always re-open to the current date, in whatever view (month/day/week) I previously used.  So if today I launch iCal and I'm thinking about adding an event a month in the future, I open iCal, change to month view if needed, and go forward one month.  This is the way iCal always worked previously.  Instead, the version in Lion might leave me on any random month, depending on what I was doing when I closed the program the last time, and so I have to figure out "what month/week am I looking at?" before I know how to navigate.  Very irritating.  (As is the move of the forward/back buttons away from the month/day/week buttons, necessitating that I move the cursor to two different areas of the screen in order to navigate.  Whose idea was THAT?)
    I haven't found a preference to resolve this bizarre behavior change.  Can anyone help?

    Hi,
    I don't know of a preference, but have you used ⌘-T in iCal?
    Best wishes
    John M

  • Can I make a checkbox populate the current date?

    I've been asked to make a form that has quite a few checkboxes.  These checkboxes also need to be marked with a date when checked off.
    Rather than have the person filling out the form type the date every time they check the box, they request that when the user clicks the checkbox that a current date show next to the checkbox.
    I don't know if this can be done with a current date stamp or with having a text box that populates with the current date, etc.
    The forms are also going to be used throughout multiple days, so I can't just call on a "current date" and show/hide that text box like I had originally thought to do.
    I'm also really green to scripting so any help or guidance in the right direction would be much appreciated.
    Thank you.

    The following Mouse Up script for a check box will set the associated text field to the current data when it's selected, and blank the field when not:
    // Mouse Up script for check box
    (function () {
        // Get a reference to the text field
        var f = getField("text1");
        // Set the value of the text field
        if (event.target.value !== "Off") {
            f.value = util.printd("mm/dd/yyyy", new Date());
        } else {
            f.value = "";
    Replace "text1" with the name of the associated text field.

  • How to display the current Date and time in xslt version 1

    i am using xslt version 1 .i want to display the current date and time in the output xml using xslt(Jdeveloper) ..i just added the namespace xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20"
         xmlns:ns1="urn:oracle:integration:b2b:7D30046DC68A4FA689956D8241FA3B99">
    and used thsi function <xsl:value-of select = "xp20:current-date()"/>
    but it does not works for me ..help needed????
    Edited by: user9519185 on Jan 20, 2009 3:04 AM

    Use a formula: =NOW()
    Format the cell for Date and Time, with both the Date part and the Time part displayed. Format the two parts as you wish, using the choices in the Inspector's menus.
    The cell will update each time the table is recalculated.
    (Description is for Numbers '09 (Mac), Numbers for iOS will be similar, but not necessarly identical in details.)
    Regards,
    Barry

Maybe you are looking for

  • Sales Orders with CO-PA characteristics

    Hello, We are using BAPI_SALESORDER_CREATEFROMDAT2 to create sales orders. According to the project specifications, we need to fill the Profitability Segment data, found in the Account Assignment tab of the item screen in transaction VA01. So far, we

  • Backup to external drive already used by Windows

    Total Mac newbie who wants to back up a MacBook Pro. I'd like to use one of the external drives I already own. The trouble is, they've been used for Windows storage already and so have that file system on them. They also have files and/or system back

  • Accessing the elements in the Runstate.S​equence.Ma​in array

    I want to change the "Record Result" property of a step on the fly. I thought I could use the function TS_SetValPropertyBoolean for this. As a lookup string I used "Runstate.Sequence.Main[i].RecordResult" but this caused a run-time error. I found tha

  • Urgent: Error during Import Metadata for IDoc

    Hi   We successfully imported the metadata for IDoc from R/3 in Development and Test box and everything worked fine. Now, when we try to import the metadata for IDoc in Production box it gives me an error" Basic type 'IDoc name' does not exist". I we

  • Printing in Book Format

    I'm experimenting and would like to print a very large document in a format resembling a book - landscape, left and right pages on one A-4 page (Eventually I'll be formatting my own A-5 book). Can someone please advise how to save it and print this w