Page 1 of 1 1
Topic Options
#210178 - 2015-03-30 04:40 PM Rename multiple files
Jasniel Offline
Getting the hang of it

Registered: 2000-04-08
Posts: 77
Hi

The filenames in the directory will be as follows:
2015-03-26-12-24-29-3226.txt
2015-03-26-13-23-23-8543.txt
2015-03-26-15-13-40-2580.txt
(File format read as YYYY-MM-DD-HH-MM-SS-XXXX.txt)

How can I rename the above multiple text files to something else? Like:
rename 2015-03-26-12-24-29-3226.txt to 1.txt
rename 2015-03-26-13-23-23-8543.txt to 2.txt
rename 2015-03-26-15-13-40-2580.txt to 3.txt

Top
#210180 - 2015-03-30 05:12 PM Re: Rename multiple files [Re: Jasniel]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
umm .. to get this straight,

you want to rename a bunch of files in a certain directory to descending numeric filenames (descending relative to "timestamp" in file name) ?

ie. newest file = 1.txt, oldest file = [amount of files].txt

Please confirm ;\)
_________________________



Top
#210182 - 2015-03-30 05:57 PM Re: Rename multiple files [Re: Jochen]
Jasniel Offline
Getting the hang of it

Registered: 2000-04-08
Posts: 77
Hi Jochen

You are right! The YYYY-MM-DD will be the same. The order is based on the HH-MM-SS.

Top
#210183 - 2015-03-30 09:31 PM Re: Rename multiple files [Re: Jasniel]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
still the order is then newest = 1, oldest = n
ok then, is the creation date of the files corresponding with the original filenames?

if we are at it, is this a dynamic folder? Means: Is the rename action you want to achieve of periodic manner? If, yes: what to do with the already renamed files?


Edited by Jochen (2015-03-30 09:33 PM)
Edit Reason: 1 leads to another ...
_________________________



Top
#210187 - 2015-03-31 05:22 AM Re: Rename multiple files [Re: Jochen]
Jasniel Offline
Getting the hang of it

Registered: 2000-04-08
Posts: 77
The creation date might not be corresponding to the filenames.

it will be a daily task. there will be 4 text files created and I will move it to another folder, and then rename each file to another filename.

The second part will be to go through the 4 files, to look for certain key words and append it to another text file. (This part of the script, I already completed).

Top
#210189 - 2015-03-31 10:21 AM Re: Rename multiple files [Re: Jasniel]
Jasniel Offline
Getting the hang of it

Registered: 2000-04-08
Posts: 77
Hi Jochen

Thanks for your help. Managed to figure it out by using the dos syntax - "type".

Type to append all the contents from the three text files to one text file.

Top
#210190 - 2015-03-31 12:04 PM Re: Rename multiple files [Re: Jasniel]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Well, glad I could help by asking the right questions
_________________________



Top
#210192 - 2015-03-31 02:07 PM Re: Rename multiple files [Re: Jochen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
All files to same file? That does not sound anything like the original question but surely is simpler...
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 739 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.059 seconds in which 0.026 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org