Rename Files in Chronological Order?

Oct 31, 2009
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
 
D

drrob1

Guest
-----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-----
 
Oct 31, 2009
3
0
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.
 
May 20, 2008
3,515
4
Elkridge, MD, USA
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
 
Oct 31, 2009
3
0
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
 
May 20, 2008
3,515
4
Elkridge, MD, USA
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
Thread starter Title Forum Replies Date
C How to? rename files with spaces Support 8
Phileosophos WAD Can't rename files in subfolders Support 1
P Rename files with ampersand in the name Support 1
C How to rename files with "(" Support 14
Joe Caverly Rename file that begins with Emoji Support 7
C Documentation Help Nit. REN / RENAME Support 0
R How to? Replace in Rename Support 9
M How to? File rename problem... Support 11
D Folders pane display problem after rename Support 0
fpefpe How to? Rename runs tree Support 10
JohnQSmith Slow network directory rename Support 8
JohnQSmith Folder pane right-click rename Support 2
samintz Regex Rename Support 2
nikbackm Rename TC tab from command line Support 0
C v28 key files Support 2
J ffind does not find files Support 4
C duplicate files in multiple plugin sites Support 9
Dmitry L. Kobyakov Fixed The SETARRAY /R command works incorrectly with cyrillic files Support 2
S How to? Deinstalling TC/reinstating execution of bat files by cmd in Win7 Support 31
vefatica FFIND, temp files? ... not deleted? Support 0
R FUNCTION to count NUMBER of files matching a pattern and specific length/not length Support 4
vefatica Tmp files from in-process pipes not deleted Support 6
vefatica Finding files with alternate data streams? Support 4
rps Multi-column DIR /v not displaying all files. Support 5
D How to skip files in a fileset? Support 6
vefatica PIPEVIEW leaves TMP files Support 18
K "copy /z /w" command not deleting read-only files in destination Support 10
Jesse Heines "Taken" date for JPG and PNG files Support 4
O I cannot use links to .btm files Support 5
R How to? Append files in multiple subfolders using copy? Support 8
Joe Caverly "Functions" in cmd.exe batch files Support 6
S Batch files Calling Batch Files Support 2
vefatica Find Files/Text dialog: does it work? Support 0
Joe Caverly UNZIPping older .ZIP files Support 3
C Documentation default location for LOG files Support 21
P exit /b in batch files Support 7
P Labels in batch files: TCC vs CMD.exe Support 9
M ANSI is used to show files instead of OEM in version 17 to 19 ! Support 5
C 7Z files on forum? Support 0
x13 Problem listing repository files using DIR http(s)://... Support 8
B Can copy command concatenate multiple mp3 files Support 2
redwdc Copying files with spaces, commas, etc. Support 5
J New lexer for TCC batch files. Support 0
M How to? want to download a file from a website enumarate the links and download the files Support 2
keithg1964 TCC RT Install Files Support 1
P Fixed Rexx .cmd files no longer work in TCC 20 Support 3
thorntonpg Handling files with embedded spaces Support 1
WavSlave Fixed Unable to sort files by description in TCC v19 Support 2
P Files older - exist Support 1
D safe delete files command Support 10

Similar threads