I have a batch script that backs up a folder to another folder etc and names the backed up folder to %date% %time% etc(only shows date currently) and I want it to show only hours and minutes. if I use %time::=.% i get 21.46.56.26 etc but I want only the 21.46 and nothing else. Script: title Backing up the universe.. echo Backing up the universe..  set savedate=%date:/=.% set savetime=%time::=.% echo Set Variable 'savedate' to %savedate% echo Set Variable 'savetime' to %savetime%  pause  md Universe-Backup\&quot;%savedate%&quot; echo Created backup folder. pause echo %savedate%  robocopy %CD%\Universe\ %CD%\Universe-Backup\\&quot;%savedate%&quot; /e  title The universe has been backedup! echo The universe has been backedup! title Starting server.. echo Starting server.. START %CD%\Server.exe
179
Update: Now that it's 2016 I'd use PowerShell for this unless there's a really compelling backwards-compatible reason for it, particularly because of the regional settings issue with using date. See @npocmaka's     What's a Windows command line statement(s) I can use to get the current datetime in a format that I can put into a filename?  I want to have a .bat file that zips up a directory into an archive with the current date and time as part of the name, for example, Code_2008-10-14_2257.zip. Is there any easy way I can do this, independent of the regional settings of the machine?  I don't really mind about the date format, ideally it'd be yyyy-mm-dd, but anything simple is fine.  So far I've got this, which on my machine gives me Tue_10_14_2008_230050_91:  rem Get the datetime in a format that can go in a filename. set _my_datetime=%date%_%time% set _my_datetime=%_my_datetime: =_% set _my_datetime=%_my_datetime::=% set _my_datetime=%_my_datetime:/=_% set _my_datetime=%_my_datetime:.=_%  rem Now use the timestamp by in a new ZIP file name. "d:\Program Files\7-Zip\7z.exe" a -r Code_%_my_datetime%.zip Code   I can live with this, but it seems a bit clunky. Ideally it'd be briefer and have the format mentioned earlier.  I'm using Windows Server 2003 and Windows&nbsp;XP Professional. I don't want to install additional utilities to achieve this (although I realise there are some that will do nice date formatting).
17395
With the ls command, is it possible to show only the files created after a specific date, hour...?  I'm asking it because I have a directory with thousand of files.  I want so see all files that were created since yesterday.   I use ls -ltr but I have to wait to see all files...  There is an equivalent of DIRECTORY/SINCE=date from OpenVMS ?
12053
I would like to keep timestamps on the commands logged in my Bash $HISTFILE, is it possible?  I did not manage to set it up using man bash as an information source.   My other options are as follows:  function thebanana() {   local -r -a bash_commands=(     "ls"     # ... more coconut commands   )   for bash_command in "${bash_commands[@]}"; do     printf "${bash_command}"     printf ":"   done } export HISTFILE=banana export HISTIGNORE="$(thebanana)" export HISTSIZE=999999 export HISTFILESIZE=999999999 export HISTCONTROL=ignoredups:erasedups   I should have mentioned I am on OS X Mountain Lion (sigh). uname -a gives me:  Darwin CoconutMac.local 12.2.0 Darwin Kernel Version 12.2.0: Sat Aug 25 00:48:52 PDT 2012; root:xnu-2050.18.24~1/RELEASE_X86_64 x86_64   and echo $BASH_VERSION gives me:  3.2.48(1)-release   Tried adding this:  export HISTTIMEFORMAT='%b %d %I:%M:%S %p '   and it only prefixes this kind of timestamps to commands:  #1349057791   I try echoing back the variable (echo $HISTTIMEFORMAT), it has the right value.  Interesting!  I even removed .profile completely to debug this. Still only funny timestamps:  #1349058320   I don't know how to further troubleshoot this... :(  Solution: I was using a script that reads the $HISTFILE directly, not the history built-in so the epoch-based timestamp (secs since Coordinated Universal Time (UTC) of January 1, 1970) was not being translated using the date formatting string. Plain-old history works fine, I'll use that instead.
112075
i've got a remote FTP server where i store some backups via cronjob.  The Problem is that i only got a little amount of space so im doing incremental backups. I want to keep the backups about 14 days.  I don't have any other access to the server except FTP and i don't now how to delete files older than x days. Every file got a name with a date in it  yxzNamezxy-date-y-m-d.tar.bz2 (datev-20100111.tar.bz2(   Hope to get some help here.  Cheers and thanks for the hopefully coming answeres,  Dennis  /Edit  I'm trying to use the curl thing which is mantioned in an answere with this part of code  curl ftp://$FTP_SERVER --user $FTP_USER:$FTP_PASS --list-only &gt; files.tmp declare -a aFiles let iCount=0 exec &lt; files.tmp while read sLine do         aFiles[$iCount]=$sLine         ((iCount++)) done  echo -e "\n Files: \n\n\n" echo ${aFiles[@]}  echo -e "\nfor ...\n\n\n" for sFile in $aFiles do         echo -e "\nFile:" $sFile done   but the secound loop doesn't give me more than 1 filename  Cheers,  Dennis
72970
I have this command that I run every 24 hours currently.  find /var/www/html/audio -daystart -maxdepth 1 -mtime +1 -type f -name "*.mp3" -exec rm -f {} \;   I would like to run it every 1 hour and delete files that are older than 1 hour. Is this correct:  find /var/www/html/audio -daystart -maxdepth 1 -mtime **+0.04** -type f -name "*.mp3" -exec rm -f {} \;   I am not sure of my use of the decimal number??  Thanks for any corrections.  EDIT  OR could I just use -mmin 60? Is this correct?  EDIT2  I tried your test, good thing you suggested it. I got an empty result. I want all files OLDER than 60mins to be deleted! How can I do this?? Does my command actually do this?
16837
I've written a quick-and-dirty script to time some reports from a web service:  BASE_URL='http://example.com/json/webservice/' FIRST=1 FINAL=10000  for report_code in $(seq 1 $FINAL); do   (time -p response=$(curl --write-out %{http_code} --silent -O ${BASE_URL}/${report_code}) ) 2&gt; ${report_code}.time    echo $response  # &lt;------- this is out of scope!  How do I fix that?   if [[ $response = '404' ]]; then     echo "Deleting report # ${report_code}!"     rm ${report_code}   else     echo "${report_code} seems to be good!"   fi done   I need to wrap the time command in a subshell so I can redirect its output, but that makes the value of $response unavailable to the parent shell.  How do I get around this problem?
54965
My script:  date echo -e "${YELLOW}Network check${NC}\n\n"  while read hostname do  ping -c 1 "$hostname" &gt; /dev/null 2&gt;&amp;1 &amp;&amp;  echo -e "Network $hostname : ${GREEN}Online${NC}" || echo -e "${GRAY}Network $hostname${NC} : ${RED}Offline${NC}"  done &lt; list.txt         sleep 30 clear done   Is outputting info like this:    Network 10.x.xx.xxx : Online    Network 10.x.xx.xxx : Offline    Network 10.x.xx.xxx : Offline    Network 10.x.xx.xxx : Offline    Network 10.x.xx.x : Online    Network 139.xxx.x.x : Online    Network 208.xx.xxx.xxx : Online    Network 193.xxx.xxx.x : Online   which I'd like to clean up to get something like this:    Network 10.x.xx.xxx       : Online   Network 10.x.xx.xxx       : Offline    Network 10.x.xx.xxx       : Offline     Network 10.x.xx.x         : Online     Network 139.xxx.x.x       : Online   Network 208.xx.xxx.xxx    : Online     Network 193.xxx.xxx.x     : Online   Network 193.xxx.xxx.xxx   : Offline
76026
I wanted to run a .bat file in Windows task scheduler, so I opened it, added a new task, browsed to the bat file, and... nothing happened.   So I changed the timing to see if it'll run, and it didn't. Next I right-clicked on the task and chose "run", it didn't run. The file itself is only one line, basicly backups a folder to a another location. It runs fine when not in the scheduler.  When I asked on  they first said to come here and the other guy said to write:  cmd.exe /C completepathtobatchfile argstobatchfileifany   So I wrote:   cmd.exe /C k:\backup.bat    and it didn't work. What do I have to change to make it work?
62048
Is there a tool for quickly backup and restore a table's data, preferably to a csv file?  It would be best if I could do it using batch. Run a .cmd file and data is backed up into a file with datetime name. And anytime needed I can just run another .cmd file to restore a file into the table.
95932
I want to start a script, which set the system time automatically after booting. I wrote the command date -s "12/31/12 23:59" in rc.d/rc.local. That didn't work. How to solve that?
38604
How can I change the local system's date &amp; time programmatically with C#?
58207
I am having date field in the UI. I have written code as per below      Datetime XXX = (Datetime)FieldName;     yyy= XXX.format('yyyyMMdd');   But after executing the batch date is decremented by 1 automatically  Can anyone suggest some idea??  Thanks in advance.
18561
I want to set the created date on some old scanned pictures to a date in 1970.  If I do that using a third party tool, Windows explorer displays the date as blank.  I thought NTFS could go back to the 1600s some time.  What is going on?
5669
If you issue ls -all command some files or directories have the year and some have the time? Why do some show the year while others show the time? Is the time representative of the time the file was created?
10378
We have a machine running Windows Server 2008, and we need to take backup of folder from a desktop on LAN. This folder is not shared.   Is there any tool or software to do this, or can a scheduled task be made which should automatically take the backup of that folder date-wise &amp; make a copy on server? Ie can we do it through Schedule Tasks option ?  Desktop systems have Windows Vista/Windows 7.
49490
I have a tab delimited file where each record has a timestamp field in 12-hour format:     mm/dd/yyyy hh:mm:ss [AM|PM].   I need to quickly convert these fields to 24-hour time:     mm/dd/yyyy HH:mm:ss.   What would be the best way to do this? I'm running on a Windows platform, but I have access to sed, awk, perl, python, and tcl in addition to the usual Windows tools.
92416
I'm copying files and folders over from one filesystem to another (both are ext3) via cp in the terminal. The 'date modified' on all of the files are being changed to the current time although I am not modifying the folder or the files. I'd like for them to keep their existing 'last modified date' which vary within the past 5 years.   I am not , but to maintain the existing 'last modified' date.  EDIT: This is still applicable for versions of ubuntu 12.04+ and newer