I have a bunch of images with different create dates. I want to normalize them all to a given date (say today's date) using a batch file (Windows). Can ExifTool set dates? I only see documentation and examples for shifting dates. To shift the date to present, I would need to somehow read the date for each file, calculate the difference, and then shift. That would be ok, but I don't know how to read the create date into a variable using ExifTool.
One obstacle for me is that I don't speak Perl. I do Python, and there is pyexiv2. This allows to write the "date", but I can't see anywhere if that is just create date or all dates.
Edit
Here shows using, for example,
exiftool -AllDates='2010:08:08 15:35:33' -overwrite_original IMG_01.jpg
in Ubuntu linux, but I could not get that to work in Windows.
As a hack, I tried
exiftool -AllDates+=2015:03:02 IMG_8220.JPG
which set the dates to the time executed, probably because the shift was so completely crazy. But I'd like to have control, and, specifically be able to change YYYY:MM:DD without changing the time.
Consequently, help still appreciated.
I crossposted to the ExifTool forum, and ExifTool author Phil Harvey responded that you need to use double quotes. The single quotes from the linked blog post don't do it in Windows.
So, one would use
exiftool -AllDates="2010:08:08 15:35:33" IMG_01.jpg
I tested it and (of course) it worked.
Related
I am working with a set of .dta files in Stata, each of which takes some time to create and each of which contains the date of creation in the file name (created at the point of saving using a macro with today's date).
At the moment my do-files identify the relevant .dta file to open based on the today's date macro, but this requires that I run the code to create the .dta files each day.
Is there a way of asking Stata to identify the most recently dated file from a set of files with same filename stem and different dates within a folder (and then open it), once I have run the "cd" command? I had a look on Statalist and SO but couldn't see an answer - any advice gratefully received.
e.g. In the folder, I have files 2020-08-23_datasetA.dta, 2020-08-22_datasetA.dta, 2020-08-22_datasetB.dta etc, and at different points I will want to select the most recently-dated version of A, B, C etc. Hence don't think a simple sort will work as there are datasets A, B, C at play.
(My question is essentially the Stata version of this one about R - Loading files with the most recent date in R)
[edited to clarify that there are multiple datasets, each of which is dated and each of which will need to be opened at different points]
Manifestly two or more files in a particular folder can't have the same name. But we know what you mean.
A utility like fs from SSC will return a list of filenames matching a pattern, alphanumerically sorted. With your dating convention the last named will be the latest as your dates follow (year, month, day) order.
Using another convention for the rest of the filename won't undermine that, but naturally you need to spell out which subset of files is of interest. So a pattern is
. ssc install fs
. fs *datasetA.dta
. local wanted = word(r(files), -1)
where the installation need only take place once. You can circumvent fs by using the calls to official Stata that it uses.
Perhaps you are seeking a program, but it's not clear to me that you need one.
Small detail: You're using the word macro in a way that doesn't match its Stata sense. Stata, for example, is not SAS! The terms code, routine and script are generic and don't conflict with any Stata use. Conversely, code, routine or script may have fixed meanings in other software you use. Either way, Stata questions are best phrased using Stata terms.
Basically I want the document to serve as some kind of journal, to record what I've done every day, so I need to add a date stamp in every entry. It should be like this:
9/14/2015
added a comma to the poem.
9/15/2015
comma deleted.
I know \date{\today} will add the date of the last compilation, but that's not what I want, and the google results are mostly about this (might be I'm search for the wrong key word).
The isodate package provides commands to switch between different date formats. You can use the following command to print a date, see the manual for details.
\printdate{09/14/2015}
The list in your example looks like a revision history, if so, take a look at the vhistory package.
Here is an example:
\documentclass{article}
\usepackage[english,num,USenglish]{isodate}
\dateinputformat{american} % mm/dd/yyyy
\usepackage{vhistory}
\begin{document}
\begin{versionhistory}
\vhEntry{1.0}{\printdate{09/14/2015}}{Olivier Ma}{added a comma to the poem.}
\vhEntry{1.1}{\printdate{09/15/2015}}{Olivier Ma}{comma deleted.}
\end{versionhistory}
\end{document}
I am making a game off Ubuntu through the terminal and one feature I would like to add is adding timestamps to the saved games.
Like the game would display "Save: (time)" and in time would be (DD/MM/YYYY HH:MM) is there a simple way to do this?
In order to get the current date you can use the command date. See man date for more format options.
$ date +'%d/%m/%y %T'
26/10/13 16:29:56
In case you would like to compute the timestamp from C++, see how to get local time and put it in a string.
How does one get yesterday's date format in a batch file?
I'd like it to look like so: M_d_yyyy
Note that if there's a single digit day and month, I'd like it to be single digits.
Example: 8_5_2013 is August 5th, 2013.
I looked around for a few days but couldn't find a solution.. any lead is much appreciated.
Nothing wrong with free 3rd party executables, but some of us are not allowed to use them on our work machines.
I have written a powerful hybrid JScript/batch utility called getTimestamp.bat that can do nearly any date and time computation on a Windows machine.
There are a great many options for specifying the base date and time, many options for adding positive or negative offsets to the date and time, many options for formatting the result, and an option to capture the result in a variable. Both input and output can be directly expressed as local time, UTC, or any time zone of your choosing. Full documentation is embedded within the script.
The utility is pure script that will run on any modern Windows machine from XP forward - no 3rd party executable required.
Assuming getTimestamp.bat is in your current directory, or better yet, somewhere within your PATH, then the following simple call will define a dt variable containing yesterday's date in M_D_YYYY format:
call getTimestamp -od -1 -f {m}_{d}_{yyyy} -r dt
Note: when I put a date in a file name, I like to use YYYY_MM_DD format because that format will sort chronologically when getting a directory listing.
I think you should get date.exe from UnxUtils.
date.exe --date="1 day ago" "+%-m_%d_%Y"
Download: http://sourceforge.net/projects/unxutils/files/unxutils/current/
Man page: http://www.ss64.com/bash/date.html
#echo off
setlocal
set magic="c:\unx\usr\local\wbin\date.exe" --date="1 day ago" "+%%-m_%%d_%%Y"
for /f %%i in ('%magic%') do set yesterdate=%%i
echo yesterdate = %yesterdate%
If you want to do it with just batch language, you'll end up with nearly 100 lines of incomprehensible batch code. UPDATE: or use dbenham's hybrid batch/JScript solution posted in the answer below, which at least uses sane Windows APIs.
See Also:
How to get current datetime on Windows command line, in a suitable format for using in a filename?
Here's an open ended question. I work on a lot of mssql files, and I like to have a date stamp on each. This is so I can know just by looking at the source of a stored procedure whether it's up to date or not.
I'd like to have a shortcut autocomplete key, that, if i type say, d-tab-tab, I get the current date printed to the file. And yes, I am that lazy. :)
So the question is:
Is there any way of getting around this problem entirely?
If not, how would you suggest solving it?
Clever ideas welcome.
Are these files in source control? If so, see whether your source control provider allows templates within the source file which get filled in with the time and date when you check in.
If you use Notepad (and this is possibly the only argument for using it) then F5 does the trick.
What about using version control for your files and including automatic keyword expansion.
Using CVS Keyword Expansion you could put $Date: $ in the file and it will get replaced with the date of the last checkin. No typing or updating needed, it's "auto-magic".