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 Fri 24 Oct 2014, 09:52
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 Posts_count  
Author Message
don570


Joined: 10 Mar 2010
Posts: 3345
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  264 Time(s) 

Edited_times_total
Back to top
View user's profile Send_private_message 
Flash
Official Dog Handler


Joined: 04 May 2005
Posts: 11121
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   445 Time(s)

number-files result 1.jpg

Back to top
View user's profile Send_private_message 
don570


Joined: 10 Mar 2010
Posts: 3345
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: 3345
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: 3345
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:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Utilities
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


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