Applescript to take a file name element to change Date Created

This so beyond me but I have been led to believe is can be done. Can anyone help me please?
I have thousands of archive files. ALL of these files' names start with the date in dd-mm-yy format. eg. 31-01-11 File Name.pdf or 25-12-09 Filename-02.pdf
I would like to be able to drag a folder onto an application and for that app to search through the folder and all sub-folders, for these files and change the files' Date Created to the date at the start of the filename.
This feels so easy to type but I fear much more complicated to do however I do thank you very much in anticipation for your help.
Best wishes
John

Hello
Here's something you might try if the problem is still open.
It uses SetFile(1) command in Developer Tools, which you need to have intalled.
cf.
http://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/m an1/SetFile.1.html
It can set creation date to any date between 1970-01-01 to 2038-01-18 inclusive.
Simple check for date in file name is implemented so that error log is written to a log file on desktop when given date is considered invalid or SetFile raises error.
One thing to note.
It will process both files and directories under given directory tree in order to process package file. But it is not smart enough to leave the package contents alone, which means if a package contains a file or directory with name matching the pattern, it's creation date will be also changed.
Minimally tested under OSX 10.2.8 at hand.
But NO WARRANTIES of any kind. Please use it on test folder first.
Good luck,
H
--SCRIPT
on open aa
main(aa)
end open
on run
open ((choose folder) as list)
end run
on main(aa)
list aa : alias list of source directories
set logf to (path to desktop)'s POSIX path & "creationdate_error_log" & (current date)'s time & ".txt"
repeat with a in aa
set a to a as alias
if (a as Unicode text) ends with ":" then -- directory
set p to a's POSIX path's text 1 thru -2 -- posix path without trailing /
set sh to "path=" & p's quoted form & ";
logf=" & logf's quoted form & ";
find "$path" -name '[0-9][0-9]-[0-9][0-9]-[0-9][0-9]*' -print0 | while read -d $'\0' f;
do
fn=${f##*/};
dd=${fn:0:2}; ((d=10#$dd));
mm=${fn:3:2}; ((m=10#$mm));
yy=${fn:6:2}; ((y=10#$yy));
if [[ ($d -ge 1 && $d -le 31) && ($m -ge 1 && $m -le 12) && ($y -ge 70 || $y -le 38) ]]; then
if [[ $y -ge 70 ]]; then
cc=19;
else
cc=20;
fi
res=$(/Developer/Tools/SetFile -d "$mm/$dd/$cc$yy 00:00" "$f" 2>&1);
if [[ -n $res ]]; then
echo "# $res ; failed for : $f" >> $logf;
fi
else
echo "# invalid date in name : $f" >> $logf;
fi
done"
do shell script sh
end if
end repeat
end main
--END OF SCRIPT

Similar Messages

  • File names with last changed Date and time in a directory

    Hi All.
    I need to get all filename, last changed date, last changed time in a directory. Is there any function module for this?
    Regards,
    Venkat.

    hi,
    if the directory is in any application server try to use this code
    >  DATA: wa_file TYPE zdpp_file_read.
    >  DATA: nomefile(75).
    >  DATA: ext_chek(3).
    >DATA: BEGIN OF wa_file,
    >        dirname     TYPE DIRNAME_AL11, " name of directory
    >        name        TYPE FILENAME_AL11," name of entry
    >        type(10)    TYPE c,            " type of entry.
    >        len(8)      TYPE p,            " length in bytes.
    >        owner(8)    TYPE c,            " owner of the entry.
    >        mtime(6)    TYPE p,            " last mod.date, sec since 1970
    >        mode(9)     TYPE c,            " like "rwx-r-x--x": prot. mode
    >        useable(1)  TYPE c,
    >        subrc(4)    TYPE c,
    >        errno(3)    TYPE c,
    >        errmsg(40)  TYPE c,
    >        mod_date    TYPE d,
    >        mod_time(8) TYPE c,            " hh:mm:ss
    >        seen(1)     TYPE c,
    >        changed(1)  TYPE c,
    >      END OF file.
    >  data: files like wa_file occurs 0 with header line.
    >
    >  CALL FUNCTION 'FILE_GET_NAME'
    >       EXPORTING
    >            client           = sy-mandt
    >            logical_filename = logpath
    >            operating_system = sy-opsys
    >       IMPORTING
    >            file_name        = path
    >       EXCEPTIONS
    >            file_not_found   = 1
    >            OTHERS           = 2.
    >  IF sy-subrc <> 0.
    >    RAISE file_not_found.
    >  ENDIF.
    >
    >  DATA: last_path TYPE i.
    >  DO.
    >    last_path = strlen( path ).
    >    last_path = last_path - 1.
    >    IF pathlast_path(1) = '/' or pathlast_path(1) = '\'.
    >      EXIT.
    >    ELSE.
    >      CLEAR path+last_path(1).
    >    ENDIF.
    >  ENDDO.
    >
    >  MOVE extension TO ext_chek.
    >  TRANSLATE ext_chek TO UPPER CASE.
    >  nomefile = '*'.
    >
    >  CALL 'C_DIR_READ_FINISH'
    >      ID 'ERRNO'  FIELD wa_file-errno
    >      ID 'ERRMSG' FIELD wa_file-errmsg.
    >
    >  CALL 'C_DIR_READ_START' ID 'DIR'    FIELD path
    >                          ID 'FILE'   FIELD nomefile
    >                          ID 'ERRNO'  FIELD wa_file-errno
    >                          ID 'ERRMSG' FIELD wa_file-errmsg.
    >  IF sy-subrc <> 0.
    >    RAISE wrong_directory.
    >  ELSE.
    >
    >    DO.
    >      CLEAR wa_file.
    >
    >      CALL 'C_DIR_READ_NEXT'
    >        ID 'TYPE'   FIELD wa_file-type
    >        ID 'NAME'   FIELD wa_file-name
    >        ID 'MTIME'  FIELD wa_file-mtime
    >        ID 'ERRNO'  FIELD wa_file-errno
    >        ID 'ERRMSG' FIELD wa_file-errmsg.
    >      IF sy-subrc <> 0.
    >        EXIT.
    >      ENDIF.
    >
    >        PERFORM p6_to_date_time_tz(rstr0400) USING wa_file-mtime
    >                                                   wa_file-mod_time
    >                                                   wa_file-mod_date.
    >      MOVE path TO wa_file-dirname.
    >      APPEND wa_file TO files.
    >    ENDDO.
    >  ENDIF.
    >
    >  CALL 'C_DIR_READ_FINISH'
    >      ID 'ERRNO'  FIELD wa_file-errno
    >      ID 'ERRMSG' FIELD wa_file-errmsg.
    bye,
    marco

  • Can you track a form if the file name has been changed after distribution?

    I created a form in Adobe Acrobat X Pro -- I then used the distribute feature and sent the form to myself using the internal server. After testing the form, and making sure all was good, I copied the attachment from the email I received when I distributed the form to myself, and sent it to my boss (via outlook). He then changed the file name, and sent the form out to our members. Our members are completing this newly-changed document instead of the original form. They are able to "Submit The Form", and it still looks as though its coming back to me via the dialogue box. However, I have no received any responses in my original document's tracking. When I tried submitting this new form myself to see what happened, I just received an message that says "Your response is being queued for submission", but it never tells you whether the form was actually submitted or not. Is there any way that you can track this form even though the file name has been changed? And if people are submitting their forms to me, where are they going?
    Please help!
    thanks,
    desiree

    I understand that you don't want to redo all the linking with the markers. You can try following (make a copy of your project first to be safe) :
    - close your project and quit DVDSP
    - move your old asset, and replace it with the new one
    - reopen your project
    A warning message should tell you that this asset has changed, but your marker will remain at old position. If the asset length are not the same, old length information will be used by DVDSP. To correct this, delete the asset from the timeline, and drop it back to the timeline.
    Now you just have to move the marker to the right position.

  • A file activation error occurred. The physical file name may be incorrect while creating database

    Hi Experts,
       I am trying to create a database in my local system, while creating i am getting error like below can anyone please help me on this.
    Msg 5105, Level 16, State 2, Line 1
    A file activation error occurred. The physical file name ' C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\NewData\Demo_dynamic.mdf' may be incorrect. Diagnose and correct additional errors, and retry the operation.
    Msg 1802, Level 16, State 1, Line 1
    CREATE DATABASE failed. Some file names listed could not be created. Check related errors. 
    Awaiting for the response......!! 
    Niraj Sevalkar

    I have created earlier database in 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA'
    but now i have created one newdata folder and trying to create in it also i have checked the path what have you suggested above and the NewData folder is existed please check below snapshot
    Both folders files and NewData folder which don't have any files 
    Niraj Sevalkar

  • Change "Date Created" on File Folders

    What is the easiest way to change or alter the "Date Created" on file folders - To a date that is 6 months older? (OS 9.1)
    I need to store my photos in a single large chronologically ordered file. Some of them are sourced from scanned photos and some are received in emails from folks.
    I want to store them in the same date order as the day the photos were taken and NOT the day I filed them.
    Thanks.........Robert

    Neil and Don,
    I figured out a way to allow me to change the "Date Created" to any date I desired.
    1. Open "Date & Time" file in "Control Panels".
    2. Set the date desired (i.e. 6 months earlier.)
    3. Then Close "Date & Time"
    4. Now in (finder) click on "Command + N",
    This creates an "untitled file folder" on the desktop
    with the newly selected "Date Created".
    5. Give the new file folder the name desired.
    6. Drag the desired files to the newly created file folder
    and drop them.
    7. Trash the OLD Date Created Folder.
    8. Remember to go back to "Date Created" in "Control
    Panels" and change back to the current date.
    The above took care of my original question; But, I decided to use the same technique to change the "FILE" date created,
    rather than the "FILE FOLDER".
    I opened my digital camera software and took a ".jpg" photo file and did a "Save As" while "Date & Time" were in the altered state. My .jpg photo file now has the new "Date Created".
    I know that Niel and Don are completely aware of such a technique, But, I figured other forum members may find this method useful.
    Thanks for all of your continuing help........Robert

  • AppleScript System Events Choose File Name Statement Broken?

    Re: OS X 10.9.2, AppleScript Editor 2.6.1:
    Why does the following AppleScript statement hang the Script Editor?
    tell application "System Events" to ¬
      choose file name with prompt "Output File" default name "Output File" default location (path to desktop)

    see Applescript Release Notes, Scripting Addition Security.
    Applescript, unlike other scripting languages, relies heavily on functionality being provided by client applications. This makes it much harder to keep consistent behavior across different contexts, because it's up to individual providers to implement applescript commands. A fact of Applescript life.
    However, it seems your real problem is not with System Events, but with the fact that your dialog is getting lost off-screen. This works:
    tell application "System Events"
      activate
      choose file name
    end tell

  • Dynamic flat file name based on selected date range

    Hi,
    I have created mapping which load data into file, i have to create file with the range specified for the data to be pulled.
    e.g if i have to load data from 01-sep-12 to 15-sep-12 the file name should be ext_rio_15-sep_to_15_sep. how can i achive through owb

    https://blogs.oracle.com/warehousebuilder/entry/dynamically_generating_target
    Cheers
    David

  • Need to add date/time stamp to file name without time change creating new files

    We have setup our application to save data once a trigger event occurs. We also need the date/time stamp as part of the file name. We used Format Date/Time String and concatenated it into the file name. It all works good, but as the time changes (seconds, minutes, etc.) it causes the Write to File to create a new file with the new filename. Is there a way to create the file and save/latch/buffer the time in the file name so that it doesn't create a new file for every second?
    I've attached a shot of the relevant part of our VI. It's all in a big while loop. The data save is in a case/switch so that when it is triggered it starts saving. (The for loop is to split the data up
    into 4 different files). Like I said, it all works except new files are created every second as the time changes instead of just putting it all in one file with the initial time in the file name.
    Attachments:
    TimeInFileNameQuestion.jpg ‏46 KB

    I need a loop in order to use a shift register. I cannot stop the outer while loop (because it would stop the hardware from collecting data), and I cannot add loops inside which bogs down the processor to where the app stops. I've attached a simpler version of my VI which illustrates the problem. While the button is pressed (the trigger) it should save the data (in this case just cycle numbers) into one file with the initial date/time. But, you can see that it creates 1 file/second. I tried using shift registers, but without adding extra loops I can't see how to do it. Thanks
    Attachments:
    FileNameTest.vi ‏29 KB

  • Should the web page address be included in the file name in the meta data dialog box?

    In the page properties > meta data > below is a field with the label file name: (the the area to type in the field), after the field, it is labeled .html.
    I have 2 questions here.
    1. If I type in http//:www (my page url), do I include .html at the end? I didn't know if this is automatically added because it is off to the side of the field?
    2. If I type in the entire URL address: http//:www (etc, etc).html,    after closing the page properties dialog box, I make it a habit to double check my work. What happens is the http//:www.xxx changes to (htttpwww.xxx). It drops the //: on the URL.
    So would it be better to just type in www.xxx (without the http//:www.xxx)
    and do you type in the .html at the end?
    I am assuming this will help with SEO page ranking or at least makes it easier for the search engines to crawl your site??
    I hope this makes sense.
    Advise would be very helpful.
    Ben

    You are absolutely correct with the URL Ben. Taking your above example, you just need to type in "Services" in the file name and the webpage will be exported as services.html and the URl will be  www.xyz.com/services.html.
    All the webpages (be it parent page or child page) gets physically saved at the root directory of your website on the server (where your website resides).
    This name is just the name of the file using which it is physically stored and called from the server. It does not help search Engines to crawl deeper inside the website.
    As I explained, "name which you wants the .html file to be stored with" here means the name of the physical file which is getting saved on the server.
    Most users leave the file name same as Page name. If you have it different from page name then this will be the workflow :
    Page Name : About
    File Name : test
    domain : www.mysite.com
    Now if you are  using a Menu Widget, it will list "About" in the Menu. And when end user will click on "About" then it will call the file named "test.html" from the server location (where all the files of your website are stored).
    And it will open a page with address "www.mysite.com/test.html"
    Hope I am able to explain the concept of File Name here. Please let us know if you have further queries on this.
    Regards,
    Sachin

  • Tracking of Attached file by File name in display changes option

    Hi All,
    i have a requirement where user wants to track the deleted file from document.
    when we go to environment-->display changes, system shows only format(wrd,xls etc) of the file which was created and deleted but how to track the file by file name once created and/or deleted.
    Thank You,
    Manoj

    Hi,
    I have created new profile and even activated, after deleting attachment from one of DIR there's no log showing for deleting the particular attachments in environment-->display changes..
    Thank You,
    Manoj

  • Setting output file name in export transaction data package

    Hi all,
    I am running an "export transaction data" package in the data manager. I wanted to set the output file name so that it will be a constant value. I wrote the following in the package editor:
    INFO(%FILE%,\ROOT\WEBFOLDERS\COLMOBIL\VEHICLES1\DATAMANGER\DATAFILES\vehicles_to_pca2.txt)
    TASK(/CPMB/TD_FILE_TARGET,FULLFILENAME,%FILE%)
    The system run the package and reported success but the file was not created. When i did the same with an existing file name, it was not updated.
    When I run the same package with the following PROMPT command instead of the INFO command:
    PROMPT(OUTFILE,,"Please enter an output file",Data files (*.txt)|*.txt|All files(*.*)|*.*)
    The system works fine.
    Any ideas?
    TIA
    Avihay

    I am sad to report that apparently Adobe does not do a very good job with the PDF printer. I have just spent over an hour with support to get the answer we can not help you. I guess I will have to spend $50 for NovaPDF to handle my problem. It's a shame when a superior overall product like Acrobat is not able to keep up with the knockoffs on the small things.

  • Changing File Names w/o Reading Data?

    Hi All,
    I'm trying to get Labview to change the name of files in a directory,
    without having to read the data.
    I'll have a variety of data sets (text, binary, PDF files, etc), and
    would like to rename them.
    Any hints? I tried using the "open/create/replace file.vi" by opening
    the file, read the file, close it, create a new file, write it, close
    it, but it doesn't work. I've also tried "copy" primitive under the
    advanced file functions, but only get new directories created with
    files in them. The following is what I got when I used it:
    For example, the directory “c:\stuff” , will have files
    "file1.aaa, file2.BBB and file3.ccc", if I want to rename
    “file1.aaa” into the file named "1file.AAA" by using the
    "copy" primitive (in the Advanced File Functions), then I get a folder
    called "1file.AAA" with the three files, "file1.aaa, file2.BBB and
    file3.ccc", in them.
    I can manipulate directories, copy files into new ones, but not rename
    files.
    Kind regards,
    -Dorian

    Spaz wrote in message news:<5065000000050000002C710000-1017707437000@exc​hange.ni.com>...
    > The Move.vi works in NT if your 'moving' to the same directory.
    Yes... I figured out what I was doing wrong. Using the "Copy"
    primitive, I was including the file name AND path, which was read as a
    new folder with the name of the file. If I remove the path, it will
    copy the files to the same directory, with the name I wanted.
    Thanks!
    -Dorian

  • File name doesn't change in Quicktime or iTunes even though i changed it in Finder

    I've have been trying to change the name of a video file (.MP4). I change the file name in the finder and it stays that way. However when i open the file in quicktime the name has not changed in the title bar. Also if i move the file to iTunes, I have it setup to copy and organize my files that i add, it changes it back to the old file name. I have all copies of the file closed. Both Quicktime and iTunes are closed. Please help me fix this. Thank you.

    You need to use a program such as VLC or Flip4Mac to play them or Switch to convert them. Just changing a file's extension doesn't change its format.
    (109393)

  • Problem importing to mp3_ file name will not change

    I have experienced this problem multiple times before and still can't find the solution.
    Every-time I Import a Cd to "MP3" a weird file name is created. When I located the mp3 after import then try to rename it. I notice that the weird file name is still saved and appears always on top of the player (quicktime)
    how do i fix this bug?

    Steve--
    Do you have the "save as a copy" checkbox checked in your "save as" dialog box? If that is checked, you save a file with the new name and keep your working filename the same. If it is not checked, you save a file with the new name and the open document filename does not change.
    If you're talking about changing the name of the file in the finder after the save, you're right. The open Photoshop document will not know that the filename has changed since the save. If you hit save, it will create a new file with the old name.

  • Report file name error with Chinese Date format

    Hello,
    I am seeing an error at
    step Write UUT report in the standard model files.  This step is
    calling the API method save on the object Runstate.Report.
    The issue occurs on computers using chinese localization with the date in the report file name.
    Is this a known issue?  Is there a way to modify the filename before calling the above method to eliminate the problem?
    Solved!
    Go to Solution.

    An Error Message is attached. 
    WE have seen this on both Vista and XP.  We are using TestStand version 4.1.1.  I am not sure about the localization, but I have seen this on computers from Taiwan, Korea and Japan.  
    If I put a breakpoint in the Model file at the Write UUT Report Step, you can see Chinese Characters in the time portion of the file name.
    If you change the report name to not include the time and date, the error does not occur.
    We have seen this with ASCII and xml.  With XML, the error also occurs at the step "Add Root Tags to XML Report"
    Attachments:
    FileNameError.JPG ‏134 KB

Maybe you are looking for

  • How can i print a list of bookmarks or extract bookmarks with number paper to print?

    How can i print a list of bookmarks or extract bookmarks with number paper to print?

  • Table entries limit

    hi, is there any limit for table entries,  because when i create or go for change in the sales order it is throwing an error called lock table entries. please help me on this issue. regards, balajia

  • Error using Webservices through ESB

    Hi Folks... I have deployed web services on some machine and Now I am tryting to contact those web services from from UI through ESB. When I create UI and run the app, Iam getting this error.. Please let me know whats the problem. I know Oracle ESB v

  • USB camera acquisition after a trigger

    I need to setup a hardware i will be using a conveyor belt and there will be coins moving on top of it linearly the conveyor will be driven by a DC motor. once the coin comes under my camera axis (sensed by an IR object sensor), my conveyor must stop

  • Issue when update ios for 7206 router

    hi all , the ios on router was 12.4 i put the ios c7200p-adventerprisek9-mz.152-4.M5.bin in disk2  , of router and added boot system flash disk2:/c7200p-adventerprisek9-mz.152-4.M5.bin after that  , i restarted the router i have the followign logs :