Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Adding zeros to filenames
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
sysiphus  
View profile  
 More options Feb 3, 7:21 am
Newsgroups: alt.os.linux.slackware
From: sysiphus <sysip...@gmail.com>
Date: Fri, 3 Feb 2012 04:21:22 -0800 (PST)
Local: Fri, Feb 3 2012 7:21 am
Subject: Adding zeros to filenames
Greetings from a longtime Slacker!

I am trying to get some help that's beyond RTFM.  I have an ebook
series in pdf that I am trying to split into its' component books.
When I split the book into pages, it numbers them
1,2,3,...10,11,12...100,101,102...etc., just like it should.  I'm
trying to arrange them to merge, but they get listed as
100,101,102.....10,11,12...1......200,201,202....20,21,22,......2, and
so on.  I need to add leading zeros to the files (two zeros to single
digit files, one zero to two digit files...) for reassembly.

Any pointers?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
sysip...@gmail.com  
View profile  
 More options Feb 3, 8:44 pm
Newsgroups: alt.os.linux.slackware
From: sysip...@gmail.com
Date: Fri, 3 Feb 2012 17:44:06 -0800 (PST)
Local: Fri, Feb 3 2012 8:44 pm
Subject: Re: Adding zeros to filenames
Figured it out.

For posterity:

for file in ??[FILENAME].pdf; do mv "$file"  "0$file"; done


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Crni Gorac  
View profile  
 More options Feb 4, 2:04 am
Newsgroups: alt.os.linux.slackware
From: Crni Gorac <cgo...@gmail.com>
Date: Fri, 3 Feb 2012 23:04:30 -0800 (PST)
Local: Sat, Feb 4 2012 2:04 am
Subject: Re: Adding zeros to filenames
Or, something like (note "sort -n", this is the most important bit for
handling situations like this):

for file in $(ls -1 *.pdf | sort -n); do
  mv $file $(printf "%03d.pdf" ${file%.pdf})
done


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Aaron W. Hsu  
View profile  
 More options Feb 7, 12:37 am
Newsgroups: alt.os.linux.slackware
From: Aaron W. Hsu <arcf...@sacrideo.us>
Date: Mon, 06 Feb 2012 23:37:32 -0600
Local: Tues, Feb 7 2012 12:37 am
Subject: Re: Adding zeros to filenames

sysiphus <sysip...@gmail.com> writes:
>I am trying to get some help that's beyond RTFM.  I have an ebook
>series in pdf that I am trying to split into its' component books.
>When I split the book into pages, it numbers them
>1,2,3,...10,11,12...100,101,102...etc., just like it should.  I'm
>trying to arrange them to merge, but they get listed as
>100,101,102.....10,11,12...1......200,201,202....20,21,22,......2, and
>so on.  I need to add leading zeros to the files (two zeros to single
>digit files, one zero to two digit files...) for reassembly.
>Any pointers?

In Slackware there is an excellent utility called rename that provides just
this sort of feature for bulk renaming of files based on patterns.

--
Aaron W. Hsu | arcf...@sacrideo.us | http://www.sacrideo.us
Programming is just another word for the lost art of thinking.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »