finding the creation date

Hi everyone,

I have a folder with many subfolders, each subfolder contains an image beginning with the letter R and finishing with the extension rvg, the full name is something like Rx.rvg where x is a variable starting from 1.

I want to get the creation date of each rvg file with the lowest x, until now I have been using this command :

find . -name "R1.rvg" -exec stat -f "%Sm %N" -t %Y%m%d%H%M%S {} \;

but unfortunately it doesn't work if the number is different than one which might be the lowest x but not all the time, please help, thank you in advance.

PS: If possible it would be better to send the output to a text file.
 
How about this little shell script?

Code:
#!/bin/sh

for dir in *; do 
    for file in $dir/R[0-9]*.rvg; do 
	stat -f "%Sm %N" -t %Y%m%d%H%M%S $file; break 1; 
    done; 
done

If you call the script blah, then run it like % blah > ~/output.txt. Don't forget to make it executable with % chmod u+x blah.
 
It says
Code:
stat: Y.RVG/R[0-9]*.rvg: stat: No such file or directory.

knowing that with the find command which does it recursively, it does find the files.
 
Here is the tree:

Parent folder
Code:
A.RVG --> A0000001 + A0000002 + A000000X
B.RVG --> A0000001 + A0000002 + A000000X
C.RVG --> A0000001 + A0000002 + A000000X
 
This isn't what I expected based on your first post. Now, I'm assuming the tree looks like

  • Parent folder
    • A.RVG (folder)
      • A0000001 (image)
        .
        .
        .
      • A000000X (image)
      .
      .
      .
    • ?.RVG (folder)
      • A0000001 (image)
        .
        .
        .
      • A000000X (image)

and for each *.RVG folder you want to find the creation date of A000000X with the smallest X.

Here is the updated script.

Code:
#!/bin/sh

for dir in *.RVG; do 
    for file in $dir/A[0-9]*; do 
	stat -f "%Sm %N" -t %Y%m%d%H%M%S $file; break 1; 
    done; 
done
 
Sorry to confuse you, I didn't describe it correctly:

Code:
KODAK (Parent folder)
A.RVG (folder)
A0000001 (Folder)
Rx.rvg(image).
.
.
A0000002 (folder)
Rx.rvg(image)..
.
.
A0000003 (folder)
Rx.rvg(image)..

?.RVG (folder)
?0000001 (folder)
Rx.rvg(image).
.
?0000002 (folder)
Rx.rvg(image).

So basically there is a parent folder with subfolders, each subfolder contains many subfolders containing images.

Thank you, I really appreciate your help.
 
Please help. It still doesn't work with the same error message (please check my last message with the path correction).
 
There might be a better way, but this is what I quickly came up with.

Code:
#!/bin/sh

for dirl1 in *.RVG; do
    for dirl2 in ${dirl1}/A[0-9]*; do
	for file in ${dirl2}/R*.rvg; do
	    stat -f "%Sm %N" -t %Y%m%d%H%M%S ${file}
	    break
	done
    done
done
 
First of all I would like to thank you for your help, it worked very well except a detail. Here is the result:

Code:
20130107095715 A.RVG/A0000065/R1.rvg
20130309211641 A.RVG/A0000066/R1.rvg
20130511092726 A.RVG/A0000067/R1.rvg
20130529114029 A.RVG/A0000068/R1.rvg
20130529160725 A.RVG/A0000069/R1.rvg
20130603161344 A.RVG/A0000070/R2.rvg
20130710125009 A.RVG/A0000071/R3.rvg
20130802130855 A.RVG/A0000072/R1.rvg
20130817070355 A.RVG/A0000073/R1.rvg
20130830091842 A.RVG/A0000074/R1.rvg
stat: B.RVG/A[0-9]*/R*.rvg: stat: No such file or directory
stat: C.RVG/A[0-9]*/R*.rvg: stat: No such file or directory
stat: D.RVG/A[0-9]*/R*.rvg: stat: No such file or directory
stat: E.RVG/A[0-9]*/R*.rvg: stat: No such file or directory
stat: F.RVG/A[0-9]*/R*.rvg: stat: No such file or directory
stat: G.RVG/A[0-9]*/R*.rvg: stat: No such file or directory
stat: H.RVG/A[0-9]*/R*.rvg: stat: No such file or directory
stat: I.RVG/A[0-9]*/R*.rvg: stat: No such file or directory
stat: J.RVG/A[0-9]*/R*.rvg: stat: No such file or directory
stat: K.RVG/A[0-9]*/R*.rvg: stat: No such file or directory
stat: L.RVG/A[0-9]*/R*.rvg: stat: No such file or directory
stat: M.RVG/A[0-9]*/R*.rvg: stat: No such file or directory
stat: N.RVG/A[0-9]*/R*.rvg: stat: No such file or directory
stat: O.RVG/A[0-9]*/R*.rvg: stat: No such file or directory
stat: Q.RVG/A[0-9]*/R*.rvg: stat: No such file or directory
stat: R.RVG/A[0-9]*/R*.rvg: stat: No such file or directory
stat: S.RVG/A[0-9]*/R*.rvg: stat: No such file or directory
stat: T.RVG/A[0-9]*/R*.rvg: stat: No such file or directory
stat: U.RVG/A[0-9]*/R*.rvg: stat: No such file or directory
stat: W.RVG/A[0-9]*/R*.rvg: stat: No such file or directory
stat: Y.RVG/A[0-9]*/R*.rvg: stat: No such file or directory
stat: Z.RVG/A[0-9]*/R*.rvg: stat: No such file or directory

Once finished with the actual letter A the script must go up and then go to the next letter which it fails to do.

I really think we're nearly there, please help, and again thank you for your help.
 
I'm making some guesses about the formats, but hopefully this will do it.

Code:
#!/bin/sh

for dirl1 in *.RVG; do
    for dirl2 in ${dirl1}/[A-Z]*[0-9]*; do
	for file in ${dirl2}/R*.rvg; do
	    stat -f "%Sm %N" -t %Y%m%d%H%M%S ${file}
	    break
	done;
    done; 
done
 
Also, for posterity, I don't think the other script sorted numerically. That is, it would have sorted R10.rvg before R2.rvg. This should do it.
Code:
#!/bin/sh

for dirl1 in *.RVG; do
    for dirl2 in ${dirl1}/[A-Z]*[0-9]*; do
        stat -f "%Sm %N" -t %Y%m%d%H%M%S \
             "$(find "${dirl2}" -name "R*.rvg" | sort -V | head -n1)"
    done;
done
 
Thanks.

Now for myself I have commands such as:

find ~/Documents -type f -exec stat -f "%SB %N" -t %Y-%m-%d\ %H:%M:%S {} \; | sort | less
 
Back
Top