Results 1 to 7 of 7

Thread: Create folders with date in name

  1. #1
    Join Date
    Jun 2012
    Beans
    29

    Create folders with date in name

    Hello everyone

    i'm hosting a small game server on a 10.04 server and i want to run some automated backup. this could be done quite easily with crotab by copying the files every day to the backup location. But how can i create a folder with the current date as name so i can keep my old backups instead of overriding them

    thx to any answers

    X D face me
    Last edited by X D face me; January 22nd, 2013 at 04:19 PM.

  2. #2
    Join Date
    Jan 2007
    Location
    Location: Location:
    Beans
    1,246
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Create folders with date in name

    mkdir `date '+%m%d%y'`

    Will create a folder with the current date, is that what you were looking for?
    clear && echo paste url and press enter; read paste; (youtube-dl $paste) | zenity --progress --title="" --text "Downloading, please wait" --auto-close --pulsate && ans=$(zenity --file-selection); gnome-terminal -x mplayer "$ans"

  3. #3
    Join Date
    Nov 2006
    Location
    Craggy Island.
    Beans
    Hidden!
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Create folders with date in name

    If I recall
    y= year in last 2 digits (13)
    Y = full year (2013)
    You can tell a man who boozes by the company he chooses, as the pig got up and slowly walked away.

  4. #4
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!

    Re: Create folders with date in name

    Quote Originally Posted by |{urse View Post
    mkdir `date '+%m%d%y'`

    Will create a folder with the current date, is that what you were looking for?
    Instead of `command`, I'd use the POSIX form of command substitution: $(command). See BashFAQ 082 (link in my signature).


    Quote Originally Posted by jonobr View Post
    If I recall
    y= year in last 2 digits (13)
    Y = full year (2013)
    Yep, you are right. The man page (`man date') also explains all the available FORMAT options.

  5. #5
    Join Date
    Jun 2012
    Beans
    29

    Re: Create folders with date in name

    the mkdir date '+%m%d%y' isn't working. i'm quite a noob on bash so please explain everything clear so i can understand it.

  6. #6
    Join Date
    Apr 2012
    Beans
    7,256

    Re: Create folders with date in name

    you need ALL the punctuation (backticks `...`) that |{urse posted - or the $(...) form as mentioned by sisco311

    Code:
    mkdir $(date '+%Y-%m-%d')
    Alternative formats that you might want to consider are '+%F' or '+%x'

  7. #7
    Join Date
    Jun 2012
    Beans
    29

    Re: Create folders with date in name

    thanks!!!!!! works now

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •