Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 24 Apr 2014, 00:55
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Utilities
Number filenames in a folder (oldest first)
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [5 Posts]  
Author Message
don570


Joined: 10 Mar 2010
Posts: 3083
Location: Ontario

PostPosted: Sat 17 Mar 2012, 15:37    Post subject:  Number filenames in a folder (oldest first)  

I wrote a small app to add numbers to filenames in a folder.

The unusual feature is that the number is dependent on the
modification date.

000 is added to the oldest file

It goes up to 999, then it repeats the numbering (I think??)
I haven't tested a folder with a large number of files Embarassed

With the method that I used it would be easy to scale the numbers up
00000 to 99999 for instance.

Instructions:

in a terminal you type


Code:
number-files  /some/folder/


A final slash / is optional, but a path is necessary


______________________________________________
number-files-1.3.pet
Description  put numbers on backend of filenames
pet

 Download 
Filename  number-files-1.3.pet 
Filesize  1.73 KB 
Downloaded  226 Time(s) 

Last edited by don570 on Thu 05 Apr 2012, 13:49; edited 3 times in total
Back to top
View user's profile Send private message 
Flash
Official Dog Handler


Joined: 04 May 2005
Posts: 10691
Location: Arizona USA

PostPosted: Sat 17 Mar 2012, 23:01    Post subject:  

I took it for a spin, renumbering the 79 mp3 files in an audio book directory. As you can see, the added numbers are not in the correct order. The files were originally numbered in order of their creation. Sad
number-files result 1.jpg
 Description   
 Filesize   73.04 KB
 Viewed   311 Time(s)

number-files result 1.jpg

Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3083
Location: Ontario

PostPosted: Tue 20 Mar 2012, 12:53    Post subject: ls command  

I'll have to check more carefully. Here's what the internet says:

Code:

6. Order Files Based on Last Modified Time Using ls -lt

To sort the file names displayed in the order of last modification time use the -t option. You will be finding it handy to use it in combination with -l option.

$ ls -lt
total 76
drwxrwxrwt  14 root root  4096 Jun 22 07:36 tmp
drwxr-xr-x 121 root root  4096 Jun 22 07:05 etc
drwxr-xr-x  13 root root 13780 Jun 22 07:04 dev
drwxr-xr-x  13 root root  4096 Jun 20 23:12 root
drwxr-xr-x  12 root root  4096 Jun 18 08:31 home
drwxr-xr-x   2 root root  4096 May 17 21:21 sbin
lrwxrwxrwx   1 root root    11 May 17 20:29 cdrom -> media/cdrom
drwx------   2 root root 16384 May 17 20:29 lost+found
drwxr-xr-x  15 root root  4096 Jul  2  2008 var



but I also used 'touch -a' which may have changed the date of
the original file????
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3083
Location: Ontario

PostPosted: Thu 22 Mar 2012, 19:27    Post subject: new version 1.1  

new version 1.1


I tracked down the bug Embarassed

I should have read the 'touch' manual more closely.

I have to tell the 'touch' command the file I want the time taken from.

There is a specific option (or switch) for this.

Also I've made sure that over-writing can't occur

by using mv -n

This app is now finished.

Go to rename-files to see the finished product
http://murga-linux.com/puppy/viewtopic.php?t=76919

_____________________________________________________
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3083
Location: Ontario

PostPosted: Thu 05 Apr 2012, 13:57    Post subject:  

New version 1.3 - Bug fix

To see how this app works in a full fledged utility program
go to Rename-files

I upgraded this app to make it run on all puppies.

I found that it would only work on Lucid Puppy because
of the limitations on the mv command.

It turns out that mv -n (non-clobber) requires a more recent
version of mv.

No file can be over written by this program
so it is safe for use. Laughing

Instructions : Just type in terminal program
Code:
number-files  /some/folder/


The files inside the folder will be numbered safely.
Any folders inside the folder will remain untouched.
A final slash / is optional, but a path is necessary.



________________________________
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [5 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Utilities
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0652s ][ Queries: 12 (0.0185s) ][ GZIP on ]