Need to rename files parsing date formats in the filename [SOLVED]

Godaddy changed the naming scheme of their server logs again.  I need some perl or something magic that will convert format A to format B.  Doing this is bash is going to be painful so I'm hoping some of your perl or python ninjas out there could help me.
format A:  ex20140425000001.log
format B: Wed, May 21, 2014.log
So for the example above, that date needs to be converted to this name: ex20140521000001.log
Thanks in advance!
EDIT: nevermind... forgot about date.
#!/bin/bash
for i in *.log; do
fixeddate="$(echo $i | sed -e 's/,//g' -e 's/^....//' -e 's/.log//')"
useitdate="$(date -d "$fixeddate" +%Y%m%d%H%M%S)"
newname="ex$useitdate.log"
mv "$i" "$newname"
done
Last edited by graysky (2014-06-07 09:41:59)

sempervirent,
You're asking for some pretty advanced file naming. Most people aren't going to need that sort of function, so I doubt there will be a hook into Aperture to do such a thing. I suggest using a shell script or Applescript along with EXIFTool to rename files before you import them into Aperture. http://www.sno.phy.queensu.ca/~phil/exiftool/
Retain the unique number that the image already has
If you're not afraid of the command line, it's easy enough to use a tool like awk or maybe perl to parse that sequence number from a well-formatted string like the picture name
Replace "DSC" with the camera model (D3X)
You can use EXIFTool to extract the camera model from the EXIF dat ain the photos
Add a digit prior to the four-digit string to indicate the true numeric sequence of the file.
Good luck with this one. You'll have to do a filename search through all of your previous files to find out what 10,000 you're on. It's possible, but you'd have to do some specialized coding in AppleScript or shell script.
nathan

Similar Messages

  • Custom batch rename files with Aperture 3 in the following format: IMG_0023.cr2 to Smith_YYMMDD_0023.cr2?  I cannot find a way to structure the date in Aperture as such, as well as extract only the camera file

    Please advise how to custom batch rename files with Aperture 3 in the following format: IMG_0023.cr2 to Smith_120816_0023.cr2?  I cannot find a way to structure the date in Aperture as such (YYMMDD), as well as extract only the camera file (0023, for example).  Adobe Bridge CS5 can do this, but NONE of the Adobe software is retina optimized, and is terrible to look at.

    In Aperture you are limited to renaming files by the entries in the File Naming preset window.
    At what point are you looking to rename, import or export? It might be possible to do what you are looking to do external to Aperture either via a script or other software.
    regards

  • Problem with SQL*Loader and different date formats in the same file

    DB: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    System: AIX 5.3.0.0
    Hello,
    I'm using SQL*Loader to import semi-colon separated values into a table. The files are delivered to us by a data provider who concatenates data from different sources and this results in us having different date formats within the same file. For example:
    ...;2010-12-31;22/11/1932;...
    I load this data using the following lines in the control file:
    EXECUTIONDATE1     TIMESTAMP     NULLIF EXECUTIONDATE1=BLANKS     "TO_DATE(:EXECUTIONDATE1, 'YYYY-MM-DD')",
    DELDOB          TIMESTAMP     NULLIF DELDOB=BLANKS          "TO_DATE(:DELDOB, 'DD/MM/YYYY')",
    The relevant NLS parameters:
    NLS_LANGUAGE=FRENCH
    NLS_DATE_FORMAT=DD/MM/RR
    NLS_DATE_LANGUAGE=FRENCH
    If I load this file as is the values loaded into the table are 31 dec 2010 and 22 nov *2032*, aven though the years are on 4 digits. If I change the NLS_DATE_FORMAT to DD/MM/YYYY then the second date value will be loaded correctly, but the first value will be loaded as 31 dec *2020* !!
    How can I get both date values to load correctly?
    Thanks!
    Sylvain

    This is very strange, after running a few tests I realized that if the year is 19XX then it will get loaded as 2019, and if it is 20XX then it will be 2020. I'm guessing it may have something to do with certain env variables that aren't set up properly because I'm fairly sure my SQL*Loader control file is correct... I'll run more tests :-(

  • Error with the data format in the TXT file, sending as an Email attachment

    Hi all,
    I have an problem in the data formating in the TXT file while sending as an attachment via an email by using the FM "SO_DOCUMENT_SEND_API1".
    For eg:
    The data in the TXT file is looking like as follows:
    0 0 0 0 2        L O U D S P E A K R   O T H E R   3 8 W h i t e                  0 0
    0031  L O U D S P E A K R   O T H E R   3 8 Black                               0 000
    38    L O U D S P E A K R   O T H E R   3 8 Brown                                  0 00040
    L O U D S P E A K R   O T H E R   3 8 Brown                                         0 00042
    and so on
    But it should come as :
    0 0 0 0 2  L O U D S P E A K R   O T H E R   3 8 W h i t e
    0 0 0031   L O U D S P E A K R   O T H E R   3 8 Black
    0 00038    L O U D S P E A K R   O T H E R   3 8 Brown
    0 00040    L O U D S P E A K R   O T H E R   3 8 Brown
    All the internal tables are correctly filled.
    The code is as follows:
    gwa_objtxt = 'Please find attached DATA EXTRACT Sheet'.
      append gwa_objtxt to git_objtxt.
    describe table git_objtxt lines gv_cnt.
      clear git_doc_data.
      read table git_objtxt index gv_cnt.
      git_doc_data-doc_size = ( gv_cnt - 1 ) * 255 + strlen( gwa_objtxt ).
      git_doc_data-obj_langu = sy-langu.
      git_doc_data-obj_descr = lv_mtitle.
      append git_doc_data.
      clear git_packing_list.
      refresh git_packing_list.
    git_packing_list-transf_bin = space.
      git_packing_list-head_start = 1.
      git_packing_list-head_num = 0.
      git_packing_list-body_start = 1.
      git_packing_list-body_num   = gv_cnt.
      git_packing_list-doc_type = 'RAW'.
      append git_packing_list.
      Clear : gv_cnt.
      Describe table git_objbin lines gv_cnt.
      git_packing_list-transf_bin = 'X'.
      git_packing_list-head_start = 1.
      git_packing_list-head_num = 1.
      git_packing_list-body_start = 1.
      git_packing_list-body_num = gv_cnt.
      git_packing_list-doc_type = 'TXT'.
      git_packing_list-obj_descr = 'ATTACH.TXT'.
      git_packing_list-obj_name = 'book'.
      git_packing_list-doc_size = gv_cnt * 255.
      APPEND git_packing_list.
      clear git_receivers.
      refresh git_receivers.
      git_receivers-receiver = gv_eid.
      git_receivers-rec_type = 'U'.
      append git_receivers.
    CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
        EXPORTING
          DOCUMENT_DATA              = git_doc_data
          PUT_IN_OUTBOX              = 'X'
          COMMIT_WORK                = 'X'
        TABLES
          PACKING_LIST               = git_packing_list
          CONTENTS_BIN               = git_objbin
          CONTENTS_TXT               = git_objtxt
          RECEIVERS                  = git_receivers
        EXCEPTIONS
          TOO_MANY_RECEIVERS              = 1
          DOCUMENT_NOT_SENT                = 2
          DOCUMENT_TYPE_NOT_EXIST      = 3
          OPERATION_NO_AUTHORIZATION = 4
          PARAMETER_ERROR                    = 5
          X_ERROR                                      = 6
          ENQUEUE_ERROR                        = 7
          OTHERS                                        = 8.

    please give the code of
    contents bin =  git_objbin " how  this is getting populated.
    0 0 0 0 2 L O U D S P E A K R O T H E R 3 8 W h i t e <b>0 0</b>
    0031 L O U D S P E A K R O T H E R 3 8 Black
    0 000
    38
    from this im not able to understand is this over population or concatenation problem
    y dont u make a append to the final table
    like
    data : begin of itxt occurs 0, ,
    s1(132) type c ,
    end of itxt.
    loop at itab.
    itxt-s1+0(4) = itab-f1.
    itxt-s1+4(6) = itab-f2.
    itxt-s1+10(8) = itab-f3.
    itxts1+18(4) = itab-f4.
    append itxt.
    clear itxt.
    endloop.
    exchange this to the contents bin of hte Fm .
    regards,
    vijay.
    can u please mail the text file and the expected o/p to my mail id [email protected]  so that i can see the same from the data provided i m not able to check the result properly .

  • Date format in the file datastore

    Hi,
    I have source as file, in which I have date column. While creating the file datastore, I have selected the datatype as date & have given the source date format in the format column and it is working fine.
    But I have source file coming with different date formats for the same column.
    My question is whether i can give multiple date formats in the format column??
    1. If yes how to separate the formats i.e with comma or semi-colon or etc...
    2. If No, thn how to achieve it. as I can use to_date function, but in that also I have to give all the date formats.

    Assuming Oracle is target database..
    Try this...
    1. In your file data store make the column as Varchar2
    2. In the interface mapping -- specify the following string in the target column mapping
    TO_DATE(REPLACE('2011-06-01','-',''),'YYYYMMDD')
    If your target column is date, Oracle will convert database proper format and insert the date..
    Hope this works out....
    Thanks
    Satish
    Edited by: user12826256 on 01-Jul-2011 02:15

  • How to handle Multiple date formats for the same date field in SQL*Loader

    Dear All,
    I got a requirement where I need to get data from a text file and insert the same into oracle table.
    I am using SQL*Loader to populate the data from the text file into my table.
    The file has one field where I am expecting date date data in multiple formats, like dd/mon/yyyy, yyyy/dd/mon, yyyy/mon/dd, ,mm/dd/yyyy, mon/dd/yyyy.
    While using SQL*Loader, I can see Loading is failing for records where we have formats like yyyy/dd/mon, yyyy/mon/dd, mon/dd/yyyy.
    Is there any way in SQL*Loader where we can mention all these date formats so that this date data should go smoothly into the underlying date column in the table.
    Appreciate your response on this.
    Thanks,
    Madhu K.

    The point being made was, are you sure that you can uniquely identify a date format from the value you receieve? Are you sure that the data stored is only of a particular limited set of formats?
    e.g. if you had a value of '07/08/03' how do you know what format that is?
    It could be...
    7th August 2003 (thus assuming it's DD/MM/RR format)
    or
    8th July 2003 (thus assuming it's MM/DD/RR format)
    or
    3rd August 2007 (thus assuming it's RR/MM/DD format)
    or
    8th March 2007 (thus assuming it's RR/DD/MM format)
    or even more obscurely...
    3rd July 2008 (MM/RR/DD)
    or
    7th March 2008 (DD/RR/MM)
    Do you have any information to tell you what formats are valid that would allow you to be specific and know what date format is meant?
    This is a classic example of why dates should be stored on the database using DATE datatype and not VARCHAR2. It can lead to corruption of data, especially if the date can be entered in any format a user wishes.

  • Setting date format for the entire SQL Server installation - SQL Server 2008 R2-2012

    Hi,
    I need to safeguard the behaviour of SQL codes that inserting into SQL tables with some date columns. For this purpose, I need to change the date format for the SQL instance and not using CONVERT and CAST.
    I've seen the SET DATE FORMAT statement, but if I use it, could I solve my problem?
    Thanks

    The language setting is related to the database user.
    BOL: "DEFAULT_LANGUAGE = { NONE | <lcid> | <language name> | <language alias> }              
    Specifies the default language for the new user. If a default language is specified for the user and the default language of the database is later changed, the users default language remains as specified.
    If no default language is specified, the default language for the user will be the default language of the database. If the default language for the user is not specified and the default language of the database is later changed, the default
    language of the user will change to the new default language for the database."
    LINK: http://technet.microsoft.com/en-us/library/ms173463.aspx
    The default language setting can be overridden by SET LANGUAGE for the session:
    http://technet.microsoft.com/en-us/library/ms174398.aspx
    Example:
    SET LANGUAGE us_english; -- mdy
    SELECT CAST ('12/13/2014' as DATE); -- 2014-12-13
    GO
    SET LANGUAGE british; -- dmy
    SELECT CAST ('12/13/2014' as DATE);
    GO
    (1 row(s) affected)
    Changed language setting to British.
    Msg 241, Level 16, State 1, Line 2
    Conversion failed when converting date and/or time from character string.
    Kalman Toth Database & OLAP Architect
    SELECT Video Tutorials 4 Hours
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • ENDDA  system date format  on the underlying system

    Hi, I have a problem , while my program runs very well on my sytem , it gives problems on other system as the date format on the other system is different. Is there any function to decide the dateformat on the runtime ?

    hi,
    use the below function modules(Any One) based on your need....
    <b>
    CONVERT_DATE_TO_EXTERNAL
    CONVERT_DATE_TO_INTERNAL</b>
    Cheers,
    Abdul Hakim

  • How do I set a custom time & date format in the top bar?

    Hello guys,
    Very embarassing question, because I've had Apple's for all of my life (starting with the original Apple Macintosh) but I still haven't figured out one thing
    How do I set a custom time & date format in the top bar?
    When I go to System Preferences > Language & Text > Formats I can set different formats. I have no idea where you will see these, but I know that it's not the top bar where the time and date is being displayed. Because no matter what I enter, the format in the top bar will stay the same. I can only choose things like 24-Hour clock or not, blinking dots and so on in the Time & Date settings from the System Preferences.
    Can anyone here point me in the right direction? I see you can even choose to display the week of the year - I'd love to do that!
    All help appreciated!
    Greetings

    Language & Text system preferences, Formats tab, customize dates.
    There are also many third party menu item utilities that can.  Search Macupdate.com for some.
    One search yielded iClock Pro.  Although I never used it I would think it allows customization.  The link I gave you is to the Macupdate download page for that app.  On that same page is a Similar Software section which has other apps that can do the same thing. 
    One listed is iStat Menus.  The primary use for iStat Menus is not for displaying date/time but it does do that.  And I know it can do what you want because I use iStat Menus to track temperature sensors n my machine and, like you, I want to customize the menu time/date.  So I use it instead of the apple clock.  It does have the customization features I think you are looking for.

  • Date format in the Web layout of Oracle 10g Reports

    Dear all,
    I want to change the date format in the oracle reports. I am using weblayout & paper layout. I have changed format mask using property inspector. It appears in paper layout. How can i get in the weblayout, please help me.
    With Regards,
    Srinivas

    Hi Srinivas,
    I think whatever applicable in Paper Layout should be applicable to Web Layout also.
    Regards,
    Raj

  • How can I permanently change the date format from the American format to the UK's without having to constantly change it manually every time I start a new spreadsheet?

    This is my first mac so I'm still getting my bearings with it. I've only used Windows programmes before. I can't understand why it's so hard to change the date format of the cells in Numbers to keep it showing the UK format. The system preferences of the mac show that it's in the correct region and has the correct date but this doesn't seem to transfer into the Numbers program. I was very impressed with the mac until I discovered this. If anyone knows how I can get the date to stay in the correct format without having to go through the process of altering it in the cell inspector everytime then I would be very grateful.

    Numbers & most apps, especially those from Apple, use the date format you have set in System Preferences > Language & Text > Region. You can then choose UK from the Region drop-down list. Mine says Custom because I've defined things further as in the second screenshot.

  • How to get the Date format inside the table

    I have a startdate column in the db in the format May 5, 2001 12:39:00 PM, when I query it from a view in this way : SELECT startdate, ... FROM ..., it returns the format in the db,
    However I have to do this SELECT
    decode(startdate, null, 'NOT START'), startdate), ... the result is 5-MAY-01,
    then I tried this to_char(startTime, 'Month DD, YYYY HH:MI: A.M.') the results become May 05, 2001 12:39:00 PM. (more space between month and day, and 05 instaed of 5)
    Does anybody know how to fix this, so I get exactly what is in the db?
    Thanks in advance

    No matter what you do if you are storing a date in a column it will get stored in the Oracle's internal 7 byte date format.
    The way you get it on retreiving it is as set by your date format. You can either change the default date format for the instance, the individual session or the individual SQL statement(in this case using to_char(date, 'format')).
    If you want to store the date in a format you want to store you'll have to store it as char or varchar2.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by George ([email protected]):
    I have a startdate column in the db in the format May 5, 2001 12:39:00 PM, when I query it from a view in this way : SELECT startdate, ... FROM ..., it returns the format in the db,
    However I have to do this SELECT
    decode(startdate, null, 'NOT START'), startdate), ... the result is 5-MAY-01,
    then I tried this to_char(startTime, 'Month DD, YYYY HH:MI: A.M.') the results become May 05, 2001 12:39:00 PM. (more space between month and day, and 05 instaed of 5)
    Does anybody know how to fix this, so I get exactly what is in the db?
    Thanks in advance<HR></BLOCKQUOTE>
    When you do to_char() with 'month' oracle blank pads the month to nine characters, the same goes with day too. So to get rid of it you'll have to trim() the month. And if you want to get a single digit for date less than 10 instead of 0x you'll have to do a bit of extra jugglery using translate() or replace().
    Hope this helps
    Naveen

  • Is there a screensnap app which uses date/time as the filename?

    I'm looking for a simple screensnap app which uses the current date/time as the filename... e.g. 010220120500 or something similar.

    Ah... automator... the ******* step-child of the OS.  Forgot about that one. I checked out your link and ran up against a barrier. I can make a sequential workflow, a date/time workflow in day/month/year and a couple other variations... but not a truly sequential day/date/year/hour/minute/second non-repeating workflow. Oddly enough I can make a hour/min/sec workflow but that would not absolutely define the file and could create duplicate filenames.
    I've looked over a lot of these screensnap apps and haven't found one that can do a non-repeating (thru system on/off sequences) filenaming thing. Maybe it can't be done.
    Automator was a good idea and it was fun using it again. Thanks Jeff.

  • Consolidating MSP Files using a variable as the filename

    Hi All
    I am trying to consolidate a number of MSP Files without having to hardcode the filenames.  Here is what I have so far and it is falling over on the Application.ConsolidateProjects..... line.  Any help/advice would be appreciated:
    Sub ImportWorkstreamPlans()
    Dim objFSO As Object
    Dim objFolder As Object
    Dim objFile As Object
    Dim i As Integer
    Dim Path As String
    Application.DisplayAlerts = False
    'Create an instance of the FileSystemObject
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    'Get the folder object
    Set objFolder = objFSO.GetFolder("D:\Delivery Assurance\CPP Build")
    i = 1
    'loops through each file in the directory and prints their names and path
    For Each objFile In objFolder.Files
    'FName = objFile
    Application.ConsolidateProjects Filenames:=objFile, NewWindow:=False, AttachToSources:=False, HideSubtasks:=True
    ViewApply Name:="CPP View"
    GroupApply Name:="No Group"
    SelectRow Row:=1, RowRelative:=False
    Next objFile
    FilterApply Name:="All Tasks"
    OutlineShowAllTasks
    SetAutoFilter FieldName:="Flag3", FilterType:=pjAutoFilterIn, Criteria1:="Yes"
    GroupApply Name:="Sub Project"
    Application.DisplayAlerts = True
    End Sub
    Thanks in anticipation.
    Tony
    TKHussar

    Tony,
    I think you made a typo when you say your individual plans are stored in "D:\CPP Build Template\CPP Plans" because your code is looking for the files in "D:|CPP Build Template\CPP
    Build Plans". Maybe that's your runtime error right there.
    However, I have to take back something I said previously. The FileName parameter of the ConsolidateProjects Method can, and should in this case, be a full path. I did a little further testing to simulate your configuration. I have a "Y" drive with
    a desktop folder. I created a blank Project 2010 template file and a simple test file and placed both of those on the "Y" drive desktop. I am running Project 2010 on the "C" drive of Windows 7 on a virtual PC. The macro code below is in
    the Global file. I open the template file and then run the macro. Everything works fine until it attempts to invoke the autofilter. Then it fails and I didn't have time to figure it out so I use a normal custom filter instead.
    Sub ImportWorkstreamPlans()
    Dim objFSO As Object
    Dim objFolder As Object
    Dim objFile As Object
    Dim i As Integer
    Dim Path As String
    Dim FName As String
    Application.DisplayAlerts = False
    'Create an instance of the FileSystemObject
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    'Get the folder object
    Set objFolder = objFSO.GetFolder("Y:\Desktop")
    i = 1
    'loops through each file in the directory, determines if they are a project file, and then inserts them into a static master
    For Each objFile In objFolder.Files
        If InStr(1, objFile.Path, ".mpp") > 0 Then
            FName = objFile.Path
            Application.ConsolidateProjects Filenames:=FName, NewWindow:=False, AttachToSources:=False, HideSubtasks:=True
            ViewApply Name:="Gantt Chart"
            GroupApply Name:="No Group"
            SelectRow Row:=1, RowRelative:=False
        End If
    Next objFile
        OutlineShowAllTasks
        FilterApply Name:="All Tasks"
        FilterEdit Name:="TKH", taskfilter:=True, create:=True, overwriteexisting:=True, _
            FieldName:="Flag3", test:="equals", Value:="yes", ShowInMenu:=False, showsummarytasks:=True
        FilterApply Name:="TKH"
        'SetAutoFilter FieldName:="Flag3", FilterType:=pjAutoFilterFlagYes
        GroupApply Name:="Sub Project"
    Application.DisplayAlerts = True
    End Sub
    John

  • URGENT: XML-SQL: Error parsing different date formats in the same XML file.

    Hi Everyone,
    I have a big problem while using the XML-SQL utility. I have a XML file with different date formats. I get exception like the one below.
    "oracle.xml.sql.OracleXMLSQLException: 'java.text.ParseException: Unparseable date:"
    And the XML file is :
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <Info Key="ID">
         <Insert>
              <ID>1</ID>
              <BookingDate>10.12.2001</BookingDate>
              <OpeningTime>19:16</OpeningTime>
         </Insert>
    </Info>
    I have tried using different setDateFormat which is contrary.
    sav.setDateFormat("d.M.y");
    sav.setDateFormat("H:m:s");
    Can someone help me on the same.
    Thanks in advance.
    Subramanian.

    You might have to describe the columns as varchar then modify the table to the right format.

Maybe you are looking for