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   -   Original Discussion by pasc
RudiC RudiC is online now Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 20 November 2017, 8:03 AM EST
Location: Aachen, Germany
Posts: 11,626
Thanks: 320
Thanked 3,617 Times in 3,322 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   -   Original Discussion by pasc
Don Cragun's Unix or Linux Image
Don Cragun Don Cragun is offline Forum Staff  
Administrator
 
Join Date: Jul 2012
Last Activity: 20 November 2017, 12:28 AM EST
Location: San Jose, CA, USA
Posts: 10,661
Thanks: 572
Thanked 3,734 Times in 3,186 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   -   Original Discussion by pasc
pasc pasc is offline
Registered User
 
Join Date: May 2011
Last Activity: 14 June 2017, 7:09 AM EDT
Posts: 140
Thanks: 26
Thanked 1 Time in 1 Post
Thanks!

Busybox seems to be rather useful Linux.
    #11  
Old Unix and Linux 10-26-2015   -   Original Discussion by pasc
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 17 November 2017, 9:25 PM EST
Location: Saskatchewan
Posts: 22,512
Thanks: 1,151
Thanked 4,273 Times in 3,946 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 09:15 AM.