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: 25 February 2017, 8:07 AM EST
Location: Aachen, Germany
Posts: 10,336
Thanks: 244
Thanked 3,162 Times in 2,920 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: 25 February 2017, 7:00 AM EST
Location: San Jose, CA, USA
Posts: 10,022
Thanks: 488
Thanked 3,463 Times in 2,951 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: 24 February 2017, 3:55 PM EST
Location: Saskatchewan
Posts: 21,938
Thanks: 1,050
Thanked 4,102 Times in 3,800 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 02:34 PM.