Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Linux find jpg and sort by date Post 303012759 by Don Cragun on Thursday 8th of February 2018 12:58:30 PM
Old 02-08-2018
Quote:
Originally Posted by apmcd47;303012730... ... ...
You mention wanting to search the whole file system. If your system has the [ICODE
locate[/ICODE], or newer mlocate package installed consider this:
Code:
locate -b -e -0 '*.jpg' | xargs -0 ls -rtd

This works for my Ubuntu 16.04 release with mlocate 0.26. The -b option forces it to check against the basename of each file; -e to ignore non-existent files (possible if you deleted files since the last update of the mlocate database, which is normally done once a day).

Andrew
Note that if you're trying to get a single list of files sorted by timestamps, anything that feeds the list to be processed to xargs is not going to achieve your goal. By definition, xargs will split the unsorted list of files into multiple sublists to be processed by executions of the target utility (ls -rtd in this case) and, although each execution will give you an ordered list, the concatenated lists produced by those multiple executions will not give you a list that is sorted by the last modification timestamps of all of the files in the list.
This User Gave Thanks to Don Cragun For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sort by Date

I'm looking to edit a file which contains various data including date.(ddmmyyyy) I want to sort by date and then count the number of different dates found Any ideas how to acheive this Thanks in advance. (2 Replies)
Discussion started by: Mudshark
2 Replies

2. Shell Programming and Scripting

how to sort by the date

Hello World~ Please Help Me(BASH) input: dde,2007.8.25,891 dde,2007.8.23,356 dfe,2007.10.12,341 cba,2005.12.5,342 I wanna know how to sort by the date(2005.12.5) output: cba,2005.12.5,342 dde,2007.8.23,356 dde,2007.8.25,891 dfe,2007.10.12,341 Thanks in advance (3 Replies)
Discussion started by: lifegeek
3 Replies

3. Shell Programming and Scripting

find jpg's mkdir script help

I am having a problem getting this to work right. The script needs to search through directories and subdirectories. If a jpg is found then create a folder in that directory, so on and so forth. Here is what I have so far but it doesn't work right. Help please #!/bin/bash for d in `find ./... (1 Reply)
Discussion started by: jedhypes
1 Replies

4. Shell Programming and Scripting

Rename all ".JPG" files to ".jpg" under all subfolders...

Hi, Dear all: One question ! ^_^ I'm using bash under Ubuntu 9.10. My question is not to rename all ".JPG" files to ".jpg" in a single folder, but to rename all ".JPG" files to ".jpg" in all subfolders. To rename all ".JPG" to ".jpg" in a single folder, for x in *.JPG; do mv "$x"... (7 Replies)
Discussion started by: jiapei100
7 Replies

5. Shell Programming and Scripting

sort the date

Hi All, Please help me to sort the date field which is in the format 2012-02-03 16:09:37.388... Platform: Red Hat linux Thanks in advance (2 Replies)
Discussion started by: jesu
2 Replies

6. Shell Programming and Scripting

Sort help: How to sort collected 'file list' by date stamp :

Hi Experts, I have a filelist collected from another server , now want to sort the output using date/time stamp filed. - Filed 6, 7,8 are showing the date/time/stamp. Here is the input: #---------------------------------------------------------------------- -rw------- 1 root ... (3 Replies)
Discussion started by: rveri
3 Replies

7. Shell Programming and Scripting

Having trouble with find rename jpg command

Hi, I have a large series of directories and subdirectories with many jpgs in them. I need to do two things: 1. Create a copy of each jpg found within it's own subdirectory 2. Rename this copied jpg such that apple.jpg becomes apple_m.jpg I have tried to run the following commands in... (1 Reply)
Discussion started by: atharvan13
1 Replies

8. Shell Programming and Scripting

Sort by name and date

nawk '$1=="Date" {d=$(NF-2);next} $1=="Queue" {q=$NF;next} $1=="Forms"{print q, $NF, d}' OFS='|' printfile.log I have this script working. Please let me know how to sort by Queue and then Date. (4 Replies)
Discussion started by: Daniel Gate
4 Replies

9. Shell Programming and Scripting

Find week of the year for given date using date command inside awk

Hi all, Need an urgent help on the below scenario. script: awk -F"," 'BEGIN { #some variable assignment} { #some calculation and put values in array} END { year=#getting it from array and assume this will be 2014 month=#getting it from array and this will be 05 date=#... (7 Replies)
Discussion started by: vijaidhas
7 Replies

10. Shell Programming and Scripting

Date: invalid date trying to set Linux date in specific format

i try to set linux date & time in specific format but it keep giving me error Example : date "+%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01" or date +"%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01" keep giving me this error : date: invalid date ‘19-01-2017 00:05:01' Please use CODE tags... (7 Replies)
Discussion started by: umen
7 Replies
EXIFTIME(1)						      General Commands Manual						       EXIFTIME(1)

NAME
exiftime - display or adjust date & time Exif tags; list files ordered by their Exif date & time tags SYNOPSIS
exiftime [-filqw] [-s delim] [-t[acdg]] [-v[+|-]val[ymwdHMS]] file ... DESCRIPTION
When invoked without arguments, the exiftime utility displays the Exif date and time tags contained in each input file to the standard out- put. Otherwise, depending on the options specified, exiftime will operate on only the chosen tags, will adjust the date and time, will write an adjusted time to each file, or will list each file in ascending order by date and time. Most digital cameras include one or more date and time tags in the Exif data added to the image files they produce. These tags are: Image Created The date and time the image was created or changed. This is the most common tag. Image Generated The date and time the original image data was generated (i.e., when picture was taken). Image Digitized The date and time the image was stored as digital data. The format for these tags is "YYYY:MM:DD HH:MM:SS" with the time shown in 24-hour format. The exiftime utility cannot add a tag if it does not already exist in file. By default, exiftime will simply print out any of the three date and time flags in each input file. The -l flag will produce a listing of each input file in date/time order, suitable for use in further image processing (e.g., production of a Web catalog) when filename ordering is not useful. The -v flag may be used to vary, or adjust, dates and times. When used with the -w flag, which writes the adjusted date and time to each input file, one may, for example, process a batch of files to adjust for a camera's incorrectly set clock. OPTIONS
-f Write adjusted date and time tags without prompting for confirmation. -i Output a prompt to standard error before overwriting a date and time tag with the adjusted value. If the response from the standard input begins with 'y' or 'Y', the tag is overwritten. This option is default behavior. -l List each input file in ascending order by timestamp. By default, it uses the Image Created tag. In the absence of an Image Cre- ated tag, first Image Generated then Image Digitized are used. Alternatively, the -t flag may be used to specify the timestamp preference for ordering. If no date and time tags are present, the OS's epoch is used. This flag overrides all others but the -t flag. -q Do not output details of a date and time adjustment to standard out when using the -w flag. -s Separate field name and value with the string delim. The default is ': '. -t Select the date and time tags for display or adjustment when followed by one or more of a (all tags), c (Image Created), d (Image Digitized), or g (Image Generated). -v Adjust the date and time tags' second, minute, hour, month day, week day, month or year according to val. If val is preceded with a plus or minus sign, the date is adjusted forwards or backwards according to the remaining string; otherwise the relevant part of the date is set. The date can be adjusted as many times as required using these flags. Flags are processed in the order given. When providing an absolute value (rather than a relative adjustment), seconds are in the range 0-59, minutes are in the range 0-59, hours are in the range 0-23, month days are in the range 1-31, week days are in the range 0-6 (Sun-Sat), months are in the range 1-12 (Jan-Dec) and years are in the range 80-38 or 1980-2038. If val is numeric, one of either y, m, w, d, H, M, or S must be used to specify which part of the date is to be adjusted. The week day or month may be specified using a name rather than a number. If a name is used with the plus (or minus) sign, the date will be put forwards (or backwards) to the next (previous) date that matches the given week day or month. This will not adjust the date, if the given week day or month is the same as the current one. When the date is adjusted to a specific value that doesn't actually exist (for example March 26, 1:30 BST 2000 in the Europe/London timezone), the date will be silently adjusted forwards in units of one hour until it reaches a valid time. When the date is adjusted to a specific value that occurs twice (for example October 29, 1:30 2000), the resulting timezone will be set so that the date matches the earlier of the two times. In all cases, daylight savings time considerations are ignored. Refer to the examples below for further details. -w Write the adjusted date and time tags. By default, any of the three date and time tags present in the file are adjusted; otherwise, only those specified with the -t flag are adjusted. EXAMPLES
The command exiftime example1.jpg will display: Image Created: 2003:09:12 17:05:37 Image Generated: 2003:09:12 17:05:37 Image Digitized: 2003:09:12 17:05:37 The command exiftime -tcd example1.jpg will display: Image Created: 2003:09:12 17:05:37 Image Digitized: 2003:09:12 17:05:37 The command exiftime -v+3H example1.jpg will adjust each time forward by three hours and display: Image Created: 2003:09:12 20:05:37 Image Generated: 2003:09:12 20:05:37 Image Digitized: 2003:09:12 20:05:37 The command exiftime -v+5d -v-7M -fw -tg *.jpg will adjust the date ahead five days and the time back seven minutes and write the adjusted date and time to the Image Generated tag with- out a prompt for confirmation for all files that match "*.jpg". It displays: example1.jpg: Image Generated: 2003:09:12 17:05:37 -> 2003:09:17 16:58:37 example2.jpg: Image Generated: 2004:01:22 17:07:02 -> 2004:01:27 17:00:02 The command exiftime -l -tdg *.jpg will list all files that match "*.jpg", one per line, in ascending timestamp order. It'll attempt to use the following timestamp values, in order: Image Digitized, Image Generated, Image Created, and, finally, the OS's epoch. DIAGNOSTICS
The exiftime utility exits 0 on success and 1 if an error occurs. SEE ALSO
exiftags(1), exifcom(1) STANDARDS
The exiftime utility was developed using the 2003 draft Exif standard, version 2.21 (http://tsc.jeita.or.jp/). BUGS
Does not support the Exif tags SubsecTime, SubsecTimeOriginal, or SubsecTimeDigitized. Does not support manufacturer-specific date and time tags. AUTHOR
The exiftime utility and this man page were written by Eric M. Johnston <emj@postal.net>. The time adjustment functionality and documenta- tion were derived from portions of FreeBSD's date(1) command by Brian Somers <brian@Awfulhak.org>. EXIFTIME(1)
All times are GMT -4. The time now is 07:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy