Daily backup file with the date in the filename

Hello,
I like to backup the same file every day of the week. And add the date in the copied filename (for example "meta09-O4-04.rtf") to automate and schedule I can use cronnix. But adding the date in the filename doesn't work for me.
As you can see in the script the backup file must be copied in a directory (for example "vis")that is in the same directory as the main file.
Can some one help me on this?
backupFileToFolder("Macintosh HD:Users:gast:Documents:meta.rtf", "Macintosh HD:Users:gast:Documents:vis:")
on backupFileToFolder(startFile, targetFolder)
set startFile to startFile as alias
set targetFolder to targetFolder as alias
tell application "Finder"
duplicate ("Macintosh HD:Users:gast:Documents:meta.rtf") to ("Macintosh HD:Users:gast:Documents:vis:")
end tell
end backupFileToFolder

But adding the date in the filename doesn't work for me.
Might help if you showed how you were trying to add the date.
That said, it shouldn't be hard to do. There are several ways of getting the date in the format you want, either via AppleScript or a simple shell command:
AppleScript:
set curDate to (get current date)
set dateStr to getYear(curDate) & "-" & getDay(curDate) & "-" & getMonth(curDate)
on getMonth(theDate)
set cM to month of theDate as integer
return text -2 through -1 of ("0" & cM)
end getMonth
on getDay(theDate)
set cD to day of theDate as text
return text -2 through -1 of ("0" & cD)
end getDay
on getYear(theDate)
set cY to year of theDate as text
return text -2 through -1 of cY
end getYear
Note this is a little more verbose than it needs to be, but it has the flexibility of formatting each date element (year, month, day) as you like.
If you want a shell version:
set dateStr to do shell script "date +%y-%d-%m"
Now you have the dateStr with the date you want, so it's easy to rename the file.
Just replace your duplicate command with the following:
set backupFile to duplicate startFile to folder targetFolder
set n to name of backupFile -- get the current file name
set nE to name extension of backupFile -- get its filename extension
set baseName to text 1 through (-1 + (length of nE)) of n -- work out the name without the extension
set newName to baseName & dateStr & "." & nE -- work out the new name using the dateStr
set name of backupFile to newName -- and rename the file

Similar Messages

  • The backup file contains unrecognized data and cannot be used

    I am trying to restore files from an NT back up on a SBS 2003.   The backup was taken on this machine and trying to restore to the same.   I get this error: The backup file contains unrecognized data and cannot be used.
    I tried copying it to a different machine with no luck.  Any suggestions?
    Robert

    Hi,
    Since the backup file cannot be restored on a different machine, the backup file could be corrupt. You need to use some third party recovery utilities to restore the backup file.
    For more detailed information, please refer to the article below:
    Windows NTBackup restore troubleshooting tips
    http://searchdatabackup.techtarget.com/tip/Windows-NTBackup-restore-troubleshooting-tips
    Please Note: Since the website is not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information.
    Best Regards,
    Mandy 
    If you have any feedback on our support, please click
    here .
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Writing a java program for generating .pdf file with the data of MS-Excel .

    Hi all,
    My object is write a java program so tht...it'll generate the .pdf file after retriving the data from MS-Excel file.
    I used POI HSSF to read the data from MS-Excel and used iText to generate .pdf file:
    My Program is:
    * Created on Apr 13, 2005
    * TODO To change the template for this generated file go to
    * Window - Preferences - Java - Code Style - Code Templates
    package forums;
    import java.io.*;
    import java.awt.Color;
    import com.lowagie.text.*;
    import com.lowagie.text.pdf.*;
    import com.lowagie.text.Font.*;
    import com.lowagie.text.pdf.MultiColumnText;
    import com.lowagie.text.Phrase.*;
    import net.sf.hibernate.mapping.Array;
    import org.apache.poi.hssf.*;
    import org.apache.poi.poifs.filesystem.*;
    import org.apache.poi.hssf.usermodel.*;
    import com.lowagie.text.Phrase.*;
    import java.util.Iterator;
    * Generates a simple 'Hello World' PDF file.
    * @author blowagie
    public class pdfgenerator {
         * Generates a PDF file with the text 'Hello World'
         * @param args no arguments needed here
         public static void main(String[] args) {
              System.out.println("Hello World");
              Rectangle pageSize = new Rectangle(916, 1592);
                        pageSize.setBackgroundColor(new java.awt.Color(0xFF, 0xFF, 0xDE));
              // step 1: creation of a document-object
              //Document document = new Document(pageSize);
              Document document = new Document(pageSize, 132, 164, 108, 108);
              try {
                   // step 2:
                   // we create a writer that listens to the document
                   // and directs a PDF-stream to a file
                   PdfWriter writer =PdfWriter.getInstance(document,new FileOutputStream("c:\\weeklystatus.pdf"));
                   writer.setEncryption(PdfWriter.STRENGTH128BITS, "Hello", "World", PdfWriter.AllowCopy | PdfWriter.AllowPrinting);
    //               step 3: we open the document
                             document.open();
                   Paragraph paragraph = new Paragraph("",new Font(Font.TIMES_ROMAN, 13, Font.BOLDITALIC, new Color(0, 0, 255)));
                   POIFSFileSystem pofilesystem=new POIFSFileSystem(new FileInputStream("D:\\ESM\\plans\\weekly report(31-01..04-02).xls"));
                   HSSFWorkbook hbook=new HSSFWorkbook(pofilesystem);
                   HSSFSheet hsheet=hbook.getSheetAt(0);//.createSheet();
                   Iterator rows = hsheet.rowIterator();
                                  while( rows.hasNext() ) {
                                       Phrase phrase=new Phrase();
                                       HSSFRow row = (HSSFRow) rows.next();
                                       //System.out.println( "Row #" + row.getRowNum());
                                       // Iterate over each cell in the row and print out the cell's content
                                       Iterator cells = row.cellIterator();
                                       while( cells.hasNext() ) {
                                            HSSFCell cell = (HSSFCell) cells.next();
                                            //System.out.println( "Cell #" + cell.getCellNum() );
                                            switch ( cell.getCellType() ) {
                                                 case HSSFCell.CELL_TYPE_STRING:
                                                 String stringcell=cell.getStringCellValue ()+" ";
                                                 writer.setSpaceCharRatio(PdfWriter.NO_SPACE_CHAR_RATIO);
                                                 phrase.add(stringcell);
                                            // document.add(new Phrase(string));
                                                      System.out.print( cell.getStringCellValue () );
                                                      break;
                                                 case HSSFCell.CELL_TYPE_FORMULA:
                                                           String stringdate=cell.getCellFormula()+" ";
                                                           writer.setSpaceCharRatio(PdfWriter.NO_SPACE_CHAR_RATIO);
                                                           phrase.add(stringdate);
                                                 System.out.print( cell.getCellFormula() );
                                                           break;
                                                 case HSSFCell.CELL_TYPE_NUMERIC:
                                                 String string=String.valueOf(cell.getNumericCellValue())+" ";
                                                      writer.setSpaceCharRatio(PdfWriter.NO_SPACE_CHAR_RATIO);
                                                      phrase.add(string);
                                                      System.out.print( cell.getNumericCellValue() );
                                                      break;
                                                 default:
                                                      //System.out.println( "unsuported sell type" );
                                                      break;
                                       document.add(new Paragraph(phrase));
                                       document.add(new Paragraph("\n \n \n"));
                   // step 4: we add a paragraph to the document
              } catch (DocumentException de) {
                   System.err.println(de.getMessage());
              } catch (IOException ioe) {
                   System.err.println(ioe.getMessage());
              // step 5: we close the document
              document.close();
    My Input from MS-Excel file is:
         Planning and Tracking Template for Interns                                                                 
         Name of the Intern     N.Kesavulu Reddy                                                            
         Project Name     Enterprise Sales and Marketing                                                            
         Description     Estimated Effort in Hrs     Planned/Replanned          Actual          Actual Effort in Hrs     Complexity     Priority     LOC written new & modified     % work completion     Status     Rework     Remarks
    S.No               Start Date     End Date     Start Date     End Date                                        
    1     setup the configuration          31/01/2005     1/2/2005     31/01/2005     1/2/2005                                        
    2     Deploying an application through Tapestry, Spring, Hibernate          2/2/2005     2/2/2005     2/2/2005     2/2/2005                                        
    3     Gone through Componentization and Cxprice application          3/2/2005     3/2/2005     3/2/2005     3/2/2005                                        
    4     Attend the sessions(tapestry,spring, hibernate), QBA          4/2/2005     4/2/2005     4/2/2005     4/2/2005                                        
         The o/p I'm gettint in .pdf file is:
    Planning and Tracking Template for Interns
    N.Kesavulu Reddy Name of the Intern
    Enterprise Sales and Marketing Project Name
    Remarks Rework Status % work completion LOC written new & modified Priority
    Complexity Actual Effort in Hrs Actual Planned/Replanned Estimated Effort in Hrs Description
    End Date Start Date End Date Start Date S.No
    38354.0 31/01/2005 38354.0 31/01/2005 setup the configuration 1.0
    38385.0 38385.0 38385.0 38385.0 Deploying an application through Tapestry, Spring, Hibernate
    2.0
    38413.0 38413.0 38413.0 38413.0 Gone through Componentization and Cxprice application
    3.0
    38444.0 38444.0 38444.0 38444.0 Attend the sessions(tapestry,spring, hibernate), QBA 4.0
                                       The issues i'm facing are:
    When it is reading a row from MS-Excel it is writing to the .pdf file from last cell to first cell.( 2 cell in 1 place, 1 cell in 2 place like if the row has two cells with data as : Name of the Intern: Kesavulu Reddy then it is writing to the .pdf file as Kesavulu Reddy Name of Intern)
    and the second issue is:
    It is not recognizing the date format..it is recognizing the date in first row only......
    Plz Tell me wht is the solution for this...
    Regards
    [email protected]

    Don't double post your question:
    http://forum.java.sun.com/thread.jspa?threadID=617605&messageID=3450899#3450899
    /Kaj

  • I have had a series of Macs.  They have been backed up with Time Machine. I am trying to restore TM backup files from the older Macs using my new MacBook Pro.  No go.  What do I do ?

    I have had a series of Macs.  They have been backed up with Time Machine. I am trying to restore TM backup files from the older Macs using my new MacBook Pro.  No go.  What do I do ?

    I am trying to restore TM backup files from the older Macs using my new MacBook Pro.  No go.
    Migration Assistant (Finder > Applications > Utilities > Migration Assistant) is the tool that you would use to restore backups from older Macs to another Mac.
    Details are here:   http://pondini.org/OSX/MigrateLion.html   The same info applies for Mavericks and Yosemite.   If you are saying that this is a "no go".....where are you getting stuck?  What error messages do you see?

  • How to make the active save-to-file with the data from GPIB ?

    Hello,,everybody !!
    I want to make the active save-to-file with the data from GPIB since starting the measurement. To save-to-file at the end of measurment is somehow risky for losing the data because my measurment have to take for long time (eg. 24-48 hours).
    Thank you in advance for anybody's help !!

    Thanks Dennis,
    I have already append, I got it but still have one small problem that between each line it has the blank line. Example as below ,
    16:40:33 54.24
    16:40:34 54.23
    16:40:35 54.24
    I want to get rid of the blank line in between.. Do you have the idea about it ?

  • What are the steps for using the backup files to reload data to my blackberry curve (8310, i think)?

    What are the steps for using the backup files to reload data to my blackberry curve (8310, i think)?

    Connect BB to PC. On 'Desktop Manager'>Backup & Restore tab>Click Restore. Double click .ipd file (backup file created from Desktop Manager).

  • Our version of ID saves all files with the time/date of December 31, 1999.  How do we fix this?

    Our version of ID saves all files with the time/date of December 31, 1999.  How do we fix this?

    That's interesting. The file date should match the system date. What's the system date? What version of InDesign? What operating system?

  • Is there a way to get back a previous iTunes backup file than the most recent Backup?

    I did a manual backup and wanted to restore the iPhone, but iTunes forced me to update the iPhone before allowing me to restore the iPhone...
    After updating, I realised that iTunes created a backup automatically without confirming with me, and now the latest backup file is not the one I wanted.
    Is there a way to get back the backup file I manually backup?

    Is there a way to get back a previous iTunes backup file than the most recent Backup?
    No, to the best of my knowledge the device backup area is simply updated with new information each time the device is backed up so there are no previous versions preserved. Once a backup has been used to restore a device however it gets locked and dated so that you could return back to that snapshot at a later date.
    Your manual backup should have simply updated the backup with any new data since the last automatic backup. Upgrading should not have overwritten a backup taken just before the upgrade with a, presumably, empty state. Have you actually tried to restore the current backup that is available? It may have what you want after all. You might like to try backing up the current state of the device to iCloud first, or if you have access to another computer back it up to that.
    N.b. I always disable automatic syncing of devices so that I am in better control of when data starts to be written, and in which direction it flows.
    ttt2

  • MY system folder, including hidden folders are littered with duplicate folders and files with the suffix (from old Mac) How do I remove them

    I have a Macbook Pro running Leopard 10.5.8. I had a problem with my my operating system (my fault, I moved a file I shoudnt have) couldnt boot up but was able to boot up from a backup. I managed to repair my original system except now all the system folders, including hidden folders are littered with duplicate folders and files with the suffix (from old Mac).  For the most part the dupes are an exact copy, but not always.  I want to remove them to free up space and cant imagine duplicate folders in the /system/library are not hindering my computer. But I dont know where to start and am afraid of doing irreparable damage. Any ideas

    pacull,
    Use iCal>View>Show Notifications to choose what to do with the notification.

  • I have a time machine backup file on a USB hard drive.  I bought a time capsule / airport extreme, flat 3TB.  I wish to transfer the backup file from the usb hard drive to the time capsule hard drive.  10.6.8

    I have a time machine backup file on a USB hard drive.  I bought a time capsule / airport extreme, flat 3TB.  I wish to transfer the backup file from the usb hard drive to the time capsule hard drive.  10.6.8

    Unfortunately, Time Machine backups that are stored on a drive that has been connected directly to a Mac are completely different than Time Machine backups that are stored on a Time Capsule.
    Frankly, it is not worth the effort and trouble to try to transfer the old backups to the new Time Capsule.....my opinion....having done this in the past.
    It is possible though, but I would not recommend it due to the complexity and downsides involved with this. To give you an idea of how to do this, check out this support article.
    http://pondini.org/TM/18.html
    Even if you transfer the "old" backups over to the Time Capsule successfully, Time Machine will not simply "add on" to the old backups.
    Time Machine will make a new complete backup of your Mac and then add incremental backups from that point.
    My advice.....start a new backup on the Time Capsule and move forward. Keep the USB hard drive around for a month, maybe 2 or 3 in case you need to go back to an old backup for some reason.  At that time, you will not likely need the old backups at all since you will have a current 2-3 month history of new backups.  At that point, you can erase the USB drive and use it for another purpose.

  • Where does Lightroom put HDR in the grid view? Is there anyway to have Lightroom stack the HDR file with the source files?

    I can't decipher where (and why) the program is putting the HDR image in the grid. I stack all of my HDR source images so they are easy to track and manage. Other apps/plugins allow you to stack resulting images with their source image. That would be great if there's a way to set that in LR preferences.

    Thanks, but this doesn't really answer the question about stacking the HDR file with the source files. Yes, it does put the file in the same folder, however many of my folders have 100s of images (that often look similar) and as far as I can tell, LR places them randomly in the sort order. It doesn't appear to put them at the beginning or end of the sort (usually by date), but somewhere randomly in the middle. Even if it could be made clear what method it is using to sort them, that would help locate one file among hundreds.
    Ideally, however it should allow you to stack with the stacked source files. Is there anyway to do this? If not, is it a feature that could be requested?

  • I also have a .csv file with the name of a jpeg in one column and a text description of each jpeg in a second column. Is there a way to automatically insert one jpeg (photo) and its corresponding text, each pair on one page, into a Indesign document?

    I also have a .csv file with the name of a jpeg in one column and a text description of each jpeg in a second column. Is there a way to automatically insert one jpeg (photo) and its corresponding text, each pair on one page, into a Indesign document?

    I would also recommend to write the description into the meta data. This would allow to place a text frame above the image and it is possible to add meta information and file name automatically together with the image, when you place it or even in a prepared template.
    Meta data information can be written easily in Bridge in the Meta File Workspace.

  • For each loop in case of more file with the same name

    Hi, guys how works ForEachLoop in case of double file? Let's say that we got five excel file. A.xls, B.xls, C.xls, D.xls, A.xls. We got two file with A.xls. I'm going to assume that both file will be loaded. It's correct? 
    I'm asking this because I need to check if I got two file with the same name ( I got hundreds of file to load). And in the same time I need to avoid to load two file with the same title ( cause I could double the data)

    If there are duplicate file names in subfolders then you should fill the variable with the complete path. See C in this images:
    Please mark the post as answered if it answers your question | My SSIS Blog:
    http://microsoft-ssis.blogspot.com |
    Twitter

  • How to open a file with the extension x3f (sigma)

    how to open a file with the extension x3f (sigma)?

    RAW data from the following Sigma cameras is currently supported:
    DP1
    DP1s
    DP2
    SD9
    SD10
    SD14
    If your camera is among these, then simply import the photo as usual. https://helpx.adobe.com/lightroom/help/importing-photos-lightroom-basic-workflow.html

  • What is the max size of a zip file with the JDK1.5 ?

    Hello everybody,
    I'm a french student and for a project, I need to create a zip file, but I don't know in advance the number and the size of files to include in my zip.
    I wish to know if someone have the answer to my question : what is the max size of a zip file with the JDK1.5 ? I believe that with the JDK1.3, the limit size of a zip was about 2Go, wasn't ?
    Thank you for all answer !
    Good day !
    PS : sorry for my very poor english ;-)

    Here is all I have found for the moment :
    ...Okay, what about my suggestion of creating your own 10GB file?
    Try this:import java.io.File;
    import java.io.RandomAccessFile;
    import java.nio.ByteBuffer;
    import java.nio.channels.FileChannel;
    import java.util.Random;
    class Main {
        public static void main(String[] args) {
            long start = System.currentTimeMillis();
            int mbs = 1024;
            writeFile("E:/Temp/data/1GB.dat", mbs);
            long end = System.currentTimeMillis();
            System.out.println("Done writing "+mbs+" MB's to disk in "+
                    ((end-start)/1000)+" seconds.");
        private static void writeFile(String fileName, int numMegaBytes) {
            try {
                int numBytes = numMegaBytes*1024*1024;
                File file = new File(fileName);
                FileChannel rwChannel =
                        new RandomAccessFile(file, "rw").getChannel();
                ByteBuffer buffer = rwChannel.map(
                        FileChannel.MapMode.READ_WRITE, 0, numBytes);
                Random rand = new Random();
                for(int i = 1; i <= numMegaBytes; i++) {
                    for(int j = 1; j <= 1024; j++) {
                        byte[] bytes = new byte[1024];
                        rand.nextBytes(bytes);
                        buffer.put(bytes);
                rwChannel.close();
            } catch(Exception e) {
                e.printStackTrace();
    }On my machine it took me 43 seconds to create a 1GB file, so it shouldn't take too long to create your own 10GB. Then try zipping that file.
    Good luck.

Maybe you are looking for

  • Rip CDs to a different location than the iTunes music folder?

    I just got my first iPod about two weeks ago: a 32 GB Touch. It's awesome. I started ripping a ton of music to my PowerBook G4's 80 GB hard drive. Now it's running out of space. I was thinking of buying a USB external drive to store all the music I w

  • Initial Transfer of Material Master to GTS

    Currently we are looking to transfer material master records(Initial) specific to only few plants as the GTS implementation is with respective to only a specific country. We have about 250,000 material master records from this plant but the MARA tabl

  • Formulas in response table not calculating

    I have two simple formulas in my response table (adding one to the number in the previous row and combining the contents of two cells), but for some reason the formulas aren't calculating when responses are added to the tables. When I click on the ce

  • Change page order of combined file

    I want to know how to change the order of a combined pdf file

  • Metadata build using Outline Load utility in 11.1.2.2

    I am looking to automate the process of metadata build using OutlineLoad utility using flat files (csv format). However the Planning Server is located on UNIX machine. Is there a way the Oracle team can place files on the Planning Server (UNIX box) o