Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Rename Files in Chronological Order?

Oct
3
0
I've got a camera that names its files in its own way. When one uses Windows Explorer to list them by filename, they're out of chronological order. Fine, but I can sort them by file date in Windows Explorer, so no problem. Right?

No, because my movie-editing software sorts the files *only* by filename, and I can't make it sort by file-date. So I've got to rename the files sequentially in their chronological order.

This is a job for 4DOS or its descendants. I've got version 5, by the way, and I'm properly registered, but (a) I haven't done any batch files in years, and (b) I don't want to update 4DOS because it'll screw up some of the batch files I've got.

Can anyone help me with a batch file that (a) lists the files in a directory by file date, oldest first; (b) takes the first file in the list and renames it 00001.xxx where xxx is the extension it already has; (c) takes the next oldest file and renames it 00002.xxx, (d) and so until all files have been renamed?

Probably a stupid request, but please humor an old fart.

--Anders R. Sterner
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Do you mean that you have 4nt version 5?

arsesq wrote:

> I've got a camera that names its files in its own way. When one uses Windows Explorer to list them by filename, they're out of chronological order. Fine, but I can sort them by file date in Windows Explorer, so no problem. Right?
>
> No, because my movie-editing software sorts the files *only* by filename, and I can't make it sort by file-date. So I've got to rename the files sequentially in their chronological order.
>
> This is a job for 4DOS or its descendants. I've got version 5, by the way, and I'm properly registered, but (a) I haven't done any batch files in years, and (b) I don't want to update 4DOS because it'll screw up some of the batch files I've got.
>
> *Can anyone help me with a batch file that (a) lists the files in a directory by file date, oldest first; (b) takes the first file in the list and renames it 00001.xxx where xxx is the extension it already has; (c) takes the next oldest file and renames it 00002.xxx, (d) and so until all files have been renamed?*
>
> Probably a stupid request, but please humor an old fart.
>
> --Anders R. Sterner
>
>
>
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkrs9jYACgkQVRqaVGo2lhy/JgCeOYkT2Fyq0rFAInrt6r36xPsa
keoAoKg1g3BCR+qtnuaQbC6mgetoUte0
=xWqP
-----END PGP SIGNATURE-----
 
Absolutely! I have 4NT 5.1 to be exact. I got 4DOS not long after its inception, and I still think of it that way. Yes, 4NT is what I mean. Even that's from long, long ago. Hopefully there won't be any compatibility issues involved in the batch-file-code solution.
 
arsesq wrote:
| *Can anyone help me with a batch file that (a) lists the files in a
| directory by file date, oldest first; (b) takes the first file in
| the list and renames it 00001.xxx where xxx is the extension it
| already has; (c) takes the next oldest file and renames it
| 00002.xxx, (d) and so until all files have been renamed?*
|
| 4nt 5

The DIR command, from early 4DOS days, had the option /od to list files in
modification order. The program below (UNTESTED!!!!) should do the trick,
probably even in 4DOS:

set t=%@unique[%temp]
dir /b /o:d *.jpg >> %t
set n=0
do fl in @%t
rename %fl %@format[08,%n].jpg
set n=%@inc[%n]
enddo
erase %t

BTW, I use a similar operation to copy image files from external media to my
PICTURES directory. I have subdirectories named yyyymm, e.g. 200911 for this
month, and rename each file from the camera in the target directory as
DDHHMMSS.* (use it also for .MOV files). Now the full path name tells me
exactly when the picture was taken, without need to get the timestamp.
--
HTH, Steve
 
Works fine, Steve, and thanks. One query: why the "erase %t" at the end? Being afraid it might erase my files, I remmed it out before I ran it.

--arsesq
 
arsesq wrote:
| Works fine, Steve, and thanks. One query: why the "erase %t" at the
| end? Being afraid it might erase my files, I remmed it out before I
| ran it.

It is a temporary file, and thus should not be left behind. Using the
procedure many times without deleting the catalog file will leave a long
trail of useless files behind.
--
HTH, Steve
 

Similar threads

Back
Top