Applescript to batch change creation dates (different dates each file)

I was pointed to an older thread that almost gets me what I need, but I'm not great with applescript, so I'm lost. Basically, I have a bunch of files. The name of the files are in a yyyymmddhhmmss.extension format (such as 20040710141231.mp4). I want to set the creation date of each file to the date by which they are all named. I found the older thread with a similar script and modified it, but I know it's not all there. I can post the whole script, but I'm pretty sure my main issue is with this part:)
                    tell originalFileCreationDate
                              set myY to year
                              set myM to text -2 through end of ("0" & (its month as integer))
                              set myD to text -2 through end of ("0" & day)
                              set myHr to text -2 through end of ("0" & (its time) div 3600)
                              set myMin to text -2 through end of ("0" & (its time) mod 3600 div 60)
                              set mySec to text -2 through end of ("0" & (its time) mod 60 as text)
                    end tell
I'm not sure how to write that to set the date based on the file name. Can someone point me in the right direction?
Thanks.

Try this instead.
This will change the access and modification times of the file:
set theDir to choose folder
do shell script "
for f in " & POSIX path of theDir & "*
do
          n=${f##*/}
          if [[ $n =~ ^[0-9]{14} ]]; then
                   touch -t ${n:0:12}.${n:12:2} \"$f\"
          fi
done

Similar Messages

  • Is is possible to batch change photos to original date?

    I'm amazed at how mixed up my photo lib is (I'd really like it to be chronological) due to edits and other mysteries. Is there a way to batch change a bunch of photos (I have 11,000 - how many should be in a "batch"?) to revert back to original date taken??? Thanks for any help! Donna

    Do Not use Shootshifter on photos already in the iPhoto Library. This will rename the files and that will damage your Library. Every file renamed will be lost to iPhoto.
    Instead, try an experiment:
    Export a few of the files from iPhoto and use Graphic Coverter (you can download a Free Trial) to examine them. See what it tells you is the date of the photo. This will tell us if the problem is with the pic or iPhoto.
    Regards
    TD

  • Batch change time only, not dates

    I have imported photos from my cell phone and have discovered that the date stamp on all of them is exactly 7 hrs fast, even though the cell phone itself displays the correct time.
    How can I change the time by exactly 7 hours on all of these imported photos (of which there are hundreds), other than one at a time? I see with batch change that you have to change to the same date and time on all your selected photos.
    Thanks.
    Barb

    It will work. Select the pics and use the Hour column to add seven hours. The date will only change adding the seven hours will push the photo past midnight.
    So, a photo tagged at 7 am on January 1 will be time shifted to 2pm on January 1
    A photo tagged at midday in January 3 will be time shifted to 7pm on January 3
    A photo tagged at 8 pm on January 4 will be time shifted to 3 am on January 5
    Back up before you try this. If it doesn't work, restore your back up.
    Regards
    TD

  • Changing creation or modification date with Automator

    Three computers access iTunes in my apartment. The files are located on a drive connect to an airport extreme base station. Each computer needs to import music and have physical access to it for iPods and playlist creation. Since iTunes does not automatically check for new files I am in the process of building an Automator script to fix the problem.
    I have created an Automator action that allows the user to control-click a folder with audio files in it and have Automator manually change the file name, then import the files into iTunes. My hope was that this would change each files modification date so that, at a later time, another Automator action could search the network drive for newly added media via the modification date. My problem is that simply changing the name does not change the modification date. Even creating an archive and unzipping it before importing does not change the date.
    What action can I do with Automator that will change the modification date on those files so that I can search for them later? I know I can add the date to the file name but I don't want a user to have to guess which dates files were added (i.e. I'd have to tell Automator "look for this specific date in the file name' which is obviously unhelpful if I don't know the specific date).
    Long story short, how can I change either dates with Automator?

    Create a column with the following.
    TIMESTAMPDIFF( SQL_TSI_day, Opportunity."Created Date" , CURRENT_TIMESTAMP )
    add a filter on this column, for example, <=90.
    the SQL_TSI_month does not return accurate number of months.
    Cheers!
    Shilei

  • Applescript to batch change "title" in Photos

    I'm trying to use the new Photos, but without being able to batch change the title, it's not going to work for me.  I saw a script in a previous post that shows how to do this, but I couldn't get it to work - apparently the script only works on small sized photo databases?  Mine has about 20,000 photos and 1,700 videos.
    Has anyone come up with a solution for this?  Photos is pretty much unusable without being able to batch change things like title (primarily) and photo name.
    Eric

    There are several Applescripts to do what you want.  They are listed in the Photos for Mac User Tips.

  • Batch change creation date meta data in Bridge?

    In Lightroom i can change the meta data on multiple files to be increased by say 2 minutes and all the creation times are adjusted.  Can this be done in CS4 bridge???

    In Bridge you can not change the date created.  That is time stamped by camera when you take the picture.

  • AppleScript to batch change 'Initial View' of PDF Documents Acrobat 9 Pro

    Hi
    I'm struggling to write a script that takes a bunch of PDF documents and opens
    those in Acrobat 9 Pro. Changes the Inital View settings (ie. Page layout = Single Page and Magnification = Fit Page)
    and saves the changes.
    Is this possible with Acrobat and AppleScript?
    Is there an AppleScript Reference for Acrobat?
    Appreciate your help.
    Cheers,
    Alex

    Well, it says Acropbat Scripting ... didn't appear to me as Windows only.
    Will move it to the Mac Forum.
    Thanks.

  • Batch change file date to match exif date

    Hi All-
    I recently got a mac pro. Upon importing my photos to iPhoto, the file date for each is set to the date of the import. When using the mac photo screensaver, the date that shows up for everything is the import date, rather than the date the photo was taken.
    Is there any way to batch change the pictures so that the file date matches the date the picture was taken?
    (Or, a way to have the screensaver use that date
    Thanks,
    -jamie

    Interesting, but here is what I found out. I was annoyed because when I sucked in about 1000 JPGs from my camera's memory stick, and then I copied them to my Windows boxen, the file dates were wrong. I was surprised that there isn't an easy way to do this... until your post!! Thanks. *APPLE, Please fix the way "Originals" are stored during iPhoto import*, since something is wrong here. The file dates stored on my memory stick should have been used not the moment I clicked import in iPhoto.
    So I moved my jhead to /usr/bin and gave it root ownership and 755 permissions.
    All of the pictures seem to be three deep here:
    cd ~/Pictures/iPhoto\ Library/Originals
    ls -lsGrt /*/.jpg
    But that is only a small fraction of mine. Most end in .JPG
    ls -lsGrt /*/.JPG
    So here is the commands to do the correction of the file date and time. You don't need the find command or that script, although you might need to snoop around and make sure all of your files are here and not any deeper or in some other location. but this should be harmless to run as long as you want to alter every file date.
    jhead -ft /*/.jpg
    jhead -ft /*/.JPG
    And that pretty much does it. I don't see any images elsewhere that were brought in by iPhoto 6 on my machine. I looked for MPG files but I don't have any. This is from a video recording camera, so I don't have any MPGs.
    So jrsmobile, my mileage varied a lot, since your method missed about 95% of my photos!!

  • Dates appear different in log file vs. debug page for Deferred Task

    I added a deferred task and in the log file, the date appeared correctly as
    Mon Dec 15 16:34:11 PST 2008
    But when I viewed the user in the debug page, the date appeared as
    <Date>2008-12-16T00:34:11.430Z</Date>
    I called an external java class that return a Date object
    <Action id='0' application='com.waveset.session.WorkflowServices'>
    <Argument name='op' value='addDeferredTask'/>
    <Argument name='date'>
    <invoke name='addWeekDays' class='MyDateUtil'/>
    </Argument>
    </Action>
    Do you have any ideas?

    IDM commonly stores dates in a Java or JDBC date format (which is what your debug date is) but often formats the date differently for log files and for web pages. It's annoying if you're trying to line two different outputs up.

  • How can I use Automator to extract specific Data from a text file?

    I have several hundred text files that contain a bunch of information. I only need six values from each file and ideally I need them as columns in an excel file.
    How can I use Automator to extract specific Data from the text files and either create a new text file or excel file with the info? I have looked all over but can't find a solution. If anyone could please help I would be eternally grateful!!! If there is another, better solution than automator, please let me know!
    Example of File Contents:
    Link Time =
    DD/MMM/YYYY
    Random
    Text
    161 179
    bytes of CODE    memory (+                68 range fill )
    16 789
    bytes of DATA    memory (+    59 absolute )
    1 875
    bytes of XDATA   memory (+ 1 855 absolute )
    90 783
    bytes of FARCODE memory
    What I would like to have as a final file:
    EXCEL COLUMN1
    Column 2
    Column3
    Column4
    Column5
    Column6
    MM/DD/YYYY
    filename1
    161179
    16789
    1875
    90783
    MM/DD/YYYY
    filename2
    xxxxxx
    xxxxx
    xxxx
    xxxxx
    MM/DD/YYYY
    filename3
    xxxxxx
    xxxxx
    xxxx
    xxxxx
    Is this possible? I can't imagine having to go through each and every file one by one. Please help!!!

    Hello
    You may try the following AppleScript script. It will ask you to choose a root folder where to start searching for *.map files and then create a CSV file named "out.csv" on desktop which you may import to Excel.
    set f to (choose folder with prompt "Choose the root folder to start searching")'s POSIX path
    if f ends with "/" then set f to f's text 1 thru -2
    do shell script "/usr/bin/perl -CSDA -w <<'EOF' - " & f's quoted form & " > ~/Desktop/out.csv
    use strict;
    use open IN => ':crlf';
    chdir $ARGV[0] or die qq($!);
    local $/ = qq(\\0);
    my @ff = map {chomp; $_} qx(find . -type f -iname '*.map' -print0);
    local $/ = qq(\\n);
    #     CSV spec
    #     - record separator is CRLF
    #     - field separator is comma
    #     - every field is quoted
    #     - text encoding is UTF-8
    local $\\ = qq(\\015\\012);    # CRLF
    local $, = qq(,);            # COMMA
    # print column header row
    my @dd = ('column 1', 'column 2', 'column 3', 'column 4', 'column 5', 'column 6');
    print map { s/\"/\"\"/og; qq(\").$_.qq(\"); } @dd;
    # print data row per each file
    while (@ff) {
        my $f = shift @ff;    # file path
        if ( ! open(IN, '<', $f) ) {
            warn qq(Failed to open $f: $!);
            next;
        $f =~ s%^.*/%%og;    # file name
        @dd = ('', $f, '', '', '', '');
        while (<IN>) {
            chomp;
            $dd[0] = \"$2/$1/$3\" if m%Link Time\\s+=\\s+([0-9]{2})/([0-9]{2})/([0-9]{4})%o;
            ($dd[2] = $1) =~ s/ //g if m/([0-9 ]+)\\s+bytes of CODE\\s/o;
            ($dd[3] = $1) =~ s/ //g if m/([0-9 ]+)\\s+bytes of DATA\\s/o;
            ($dd[4] = $1) =~ s/ //g if m/([0-9 ]+)\\s+bytes of XDATA\\s/o;
            ($dd[5] = $1) =~ s/ //g if m/([0-9 ]+)\\s+bytes of FARCODE\\s/o;
            last unless grep { /^$/ } @dd;
        close IN;
        print map { s/\"/\"\"/og; qq(\").$_.qq(\"); } @dd;
    EOF
    Hope this may help,
    H

  • Can I use Bridge to export image data into a .txt file?

    I have a folder of images and I would like to export the File Name, Resolution, Dimensions and Color Mode for each file into one text file. Can I use Bridge to export image data into a .txt file?

    Hello
    You may try the following AppleScript script. It will ask you to choose a root folder where to start searching for *.map files and then create a CSV file named "out.csv" on desktop which you may import to Excel.
    set f to (choose folder with prompt "Choose the root folder to start searching")'s POSIX path
    if f ends with "/" then set f to f's text 1 thru -2
    do shell script "/usr/bin/perl -CSDA -w <<'EOF' - " & f's quoted form & " > ~/Desktop/out.csv
    use strict;
    use open IN => ':crlf';
    chdir $ARGV[0] or die qq($!);
    local $/ = qq(\\0);
    my @ff = map {chomp; $_} qx(find . -type f -iname '*.map' -print0);
    local $/ = qq(\\n);
    #     CSV spec
    #     - record separator is CRLF
    #     - field separator is comma
    #     - every field is quoted
    #     - text encoding is UTF-8
    local $\\ = qq(\\015\\012);    # CRLF
    local $, = qq(,);            # COMMA
    # print column header row
    my @dd = ('column 1', 'column 2', 'column 3', 'column 4', 'column 5', 'column 6');
    print map { s/\"/\"\"/og; qq(\").$_.qq(\"); } @dd;
    # print data row per each file
    while (@ff) {
        my $f = shift @ff;    # file path
        if ( ! open(IN, '<', $f) ) {
            warn qq(Failed to open $f: $!);
            next;
        $f =~ s%^.*/%%og;    # file name
        @dd = ('', $f, '', '', '', '');
        while (<IN>) {
            chomp;
            $dd[0] = \"$2/$1/$3\" if m%Link Time\\s+=\\s+([0-9]{2})/([0-9]{2})/([0-9]{4})%o;
            ($dd[2] = $1) =~ s/ //g if m/([0-9 ]+)\\s+bytes of CODE\\s/o;
            ($dd[3] = $1) =~ s/ //g if m/([0-9 ]+)\\s+bytes of DATA\\s/o;
            ($dd[4] = $1) =~ s/ //g if m/([0-9 ]+)\\s+bytes of XDATA\\s/o;
            ($dd[5] = $1) =~ s/ //g if m/([0-9 ]+)\\s+bytes of FARCODE\\s/o;
            last unless grep { /^$/ } @dd;
        close IN;
        print map { s/\"/\"\"/og; qq(\").$_.qq(\"); } @dd;
    EOF
    Hope this may help,
    H

  • Batch change dpi from 72 to 300 and export as jpg

    Hi All,
    I have searched high and low, and have yet to find a script that will accomplish this task. I am in need of a script that will change Illustrator's default 72 dpi, to 300 dpi so I can print a series of (about 200) respectable looking images. They also need to be exported to jpg.
    Is this possible to do in batch?
    I have tried countless approaches. The closest I have come is using Graphic Converter Pro, unfortunately it cannot change the dpi from 72 to 300 (as far as I could tell). Any help is greatly appreciated. I have access to Mac OS and Windows. I've been trying to tackle this for quite some time. Thank you!

    Hi, thanks for your responses. I do have Photoshop. What I am trying to do is take about 100 .ai files and export them to .jpg. However, they are going to be printed, and any sort of batch export as .jpg I have tried so far has resulted in substantial resolution (72 dpi). I am well aware of how to change the resolution for exporting each file individually, however what I want to do is batch the whole process together. I will try the resizing approach. Thanks both of you!

  • Change Directory Structure Created in MPZIP file

    I'm trying to standardize my Multisim projects for inclusion in our documentation control system. As I build my project, I have a directory structure that I'm using. When I include the files in the project, the directory structure is remembered in the MPZIP file. However, the default is to unpack all files into the External(Project Name) folder. Following the help, 
    Extracted Path—The location to which the files will be extracted. The default is <project name>External\filename, for example project1External\amplifier.ms12. Use the drop-down lists in the Extracted Path column to select other locations as desired. 
    I can go in and change the directory path of each file using pull-down boxes. This makes  a manual process and if I include datasheets, specifications, and dxf files, is quite time intensive. Is there a way to default to having the project to unpack to the old directory structure? Is there some other way to automate the unpacking? I can manually zip the old project structure, but other than the form of the directories, the MPZIP is so convenient.
    Solved!
    Go to Solution.

    Hi Doug,
    When you unpack the project, the default is to create a new folder and put everything together since it is unlikely that the new computer will have the same file structure as the computer where this project came from.  If you want Multisim to create the same file structure as the original, you can click in the cell under "extracted path" and select the old path, if the folder doesn't exist, Multisim will create one.  Unfortunately, you will have to do this for each item on the table.
    Tien P.
    National Instruments
    Attachments:
    unpack.png ‏17 KB

  • Change creation date with Applescript?  Any one?

    Is any one good with writing AppleScript?  I've looked in the Help menu and I don't understand it.
    I have a folder of over 1,000 pictures that has the incorrect "Date Created."   The correct date is actually in the "Date Modified" info for each picture.  I have no idea how this came to be.
    Given that there are so many files in the folder, using the "Touch -t" command in Terminal for each one individually is.. well.. daunting. 
    If any one knows how to write a quick Script to copy the "Date Modified" to the "Date Created" information going through each file in a folder (automated), karma would look good on you. 
    I've been going through page after page of web-search results of "change date created mac app" with no such luck.
    (OS 10.8.2)
    Thanks to any one that can help in any way. 

    Hi,
    touch -t can change the creation date, but it can only set backward, not forward.
    Here is a AppleScript that uses the class NSFileManager from the Foundation framework to change the file's creation date.
    -- this script set the creation date of each file to the file's modification date
    -- When the dialog will appear, just select the files whose creation date is incorrect.
    set pathErr to getFiles()
    if pathErr is not "" then -- if error on some file
      activate
              display dialog "Done, but the creation date of some files have not been changed"
              tell application "TextEdit"
      activate
                        make new document at end of documents with properties {text:("  The creation date of these files have not been changed :" & pathErr)}
      end tell
    else
              display dialog "The creation date of all the files have been changed."
    end if
    on getFiles()
      script o
                        property tFiles : {}
      end script
      set o's tFiles to choose file with multiple selections allowed without invisibles
              set t to ""
              set tError to ""
      set tc to count o's tFiles
      repeat with i from 1 to tc
                        set t to t & " " & quoted form of POSIX path of (item i of o's tFiles)
      if (i mod 250) = 0 or i = tc then -- 250 files sent to the shell to not exceed the limit of characters.
      set r to my setCreationDateToModDate(t)
                                  if r is not "" then set tError to tError & return & r
                                  set t to ""
      end if
      end repeat
      return tError
    end getFiles
    on setCreationDateToModDate(theseFiles)
              do shell script "/usr/bin/env python -c 'import os, sys
    from Foundation import NSFileManager
    df = NSFileManager.defaultManager()
    nbr=len(sys.argv)
    for i in range( 1, nbr ):
       f = sys.argv[i]
       my_dict, error = df.attributesOfItemAtPath_error_(f, None)
       if error is None:
          mDate = my_dict.fileModificationDate()
          cDateDict = {\"NSFileCreationDate\":mDate}
          b, error = df.setAttributes_ofItemAtPath_error_(cDateDict , f, None)
          if not b: print f' " & theseFiles
    end setCreationDateToModDate
    Works on OS X 10.5.x or newer.

  • Changing creation date on adobe acrobat 9

    I've got a folder full of old PDF files at work. They are all labeled DD-MM-YY to signify the date they were made but the pdf's were originally in Word format and when they were all converted to PDF's, they all took that day as their created date. I'm looking for a way to change the created date on these hundreds of PDF's to match the date in the file name. Is there an easy way to do this?  I have to print the documents and organize them chronologically by date.  However, I need to also have corresponding creation dates with the documents.  I'm not good with scripting or programming however I am great at following step by step directions.  I would greatly appreciate help on this since this is a semi time sensitive project.
    Thank you.

    Acrobat does not offer any way to change creation date. It is correct: by definition, it is the day when the PDF was made, it is not supposed to be set to a different date that might be more convenient.

Maybe you are looking for

  • Safe mode problem

    Had kernel panic and started in safe mode. Checked memory- showing17.8 GB. Now can't log on even in safe mode. Screen goes pink and blue and distorts

  • What's in YOUR Pictures folder?

    Is there any problem with using the Pictures folder in the Finder to hold every image on your Mac without any hierarchy or additional folders for order? Is it wrong or dangerous to simply dump thousands of images here without any attempt at file mana

  • How to embed html into keynote

    I want to embed the youtube code for a vid into my keynote presentation so when I export to flash I can post the entire thing online, the presentation will work and I can watch the vid too. Any thoughts on how to embed html into a keynote page? Thank

  • OIM 11g giving roles

    Hi all. I'm trying to customize the self-registration feature in such a way. In particular I need that after the self-registration, a user automatically get assigned to a specific role. By default OIM assign to all registered users "ALL USERS" role (

  • Tried to update Firefox, it appeared to be successful, but when I try to launch it, it asks me to reboot. I even tried to remove it, but it just asks me to reboot, which I did with no result.

    When I try to launch the app, it says I must restart to complete an upgrade of Firefox. I reboot, but nothing changes. It just keeps asking me to restart the computer. I even tried to do add/remove, but all I get is that incredibly annoying dialog bo