Unix/Linux Go Back    


Windows & DOS: Issues & Discussions All Windows and DOS questions should go here as well. Discuss UNIX to Windows (Desktop or Server) here!

Simple 'date' to 001 scheme script

Windows & DOS: Issues & Discussions


Closed    
 
Thread Tools Search this Thread Display Modes
    #8  
Old Unix and Linux 10-20-2015
RudiC RudiC is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 22 January 2017, 7:06 AM EST
Location: Aachen, Germany
Posts: 10,158
Thanks: 230
Thanked 3,073 Times in 2,849 Posts
Not sure as this seems to be for DOS - is the %d a format string that could be replaced by e.g. %04d (as opposed to %x which is a loop variable)?
Sponsored Links
    #9  
Old Unix and Linux 10-20-2015
Don Cragun's Unix or Linux Image
Don Cragun Don Cragun is offline Forum Staff  
Administrator
 
Join Date: Jul 2012
Last Activity: 22 January 2017, 3:24 AM EST
Location: San Jose, CA, USA
Posts: 9,862
Thanks: 476
Thanked 3,385 Times in 2,891 Posts
With the shell in busybox you should be able to do something like:

Code:
cnt=1
for x in *.gif
do      base="${x%.gif}"
        echo mv "$x" "$(printf '%s_%04d.gif' "$base" $cnt)"
        cnt=$((cnt + 1))
done

If that shows you a set of mv commands that do what you need to do, remove the echo and run it again to actually rename the files.
The Following User Says Thank You to Don Cragun For This Useful Post:
pasc (10-20-2015)
Sponsored Links
    #10  
Old Unix and Linux 10-20-2015
pasc pasc is offline
Registered User
 
Join Date: May 2011
Last Activity: 20 October 2015, 7:24 AM EDT
Posts: 139
Thanks: 26
Thanked 1 Time in 1 Post
Thanks!

Busybox seems to be rather useful Linux.
    #11  
Old Unix and Linux 10-26-2015
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 20 January 2017, 5:46 PM EST
Location: Saskatchewan
Posts: 21,780
Thanks: 1,027
Thanked 4,038 Times in 3,746 Posts
Quote:
Originally Posted by RudiC View Post
Not sure as this seems to be for DOS - is the %d a format string that could be replaced by e.g. %04d (as opposed to %x which is a loop variable)?
He could likely feed that to imagemagick next time to get files with leading zeroes from the get-go.
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to do simple date (time) calculation in shell script? nbsparks Shell Programming and Scripting 7 09-16-2013 06:59 PM
Help making simple perl or bash script to create a simple matrix torchij Shell Programming and Scripting 16 04-26-2012 05:05 AM
How can get the value 001 using shell script nmadhuhb Shell Programming and Scripting 2 07-20-2009 07:36 AM
Simple date formatting? muay_tb Shell Programming and Scripting 4 05-01-2009 11:08 AM
a simple way of converting a date in seconds to normal date travian HP-UX 2 11-23-2006 12:25 PM



All times are GMT -4. The time now is 12:26 PM.