Posts Tagged ‘rename’

Download all issues of Full Circle Magazine

January 27, 2011 5 comments


You want to get all the issues of Full Circle Magazine but you don’t want to download ’em one by one. Is there an easy and painless way to get them in a bundle?


Here are the necessary URLs till issue 47:

Save it to a file called down.txt, then download them all:

wget -i down.txt

Update (20110130) #1:

Unfortunately, issues below 10 are named as issueX_en.pdf and not as issue0X_en.pdf. Thus, if you download all the files and list them with ‘ls -al‘, issues < 10 will be mixed with the others. Here is how to fix it:

rename -n 's/issue(\d)_en(.*)/issue0$1_en$2/' *.pdf

It will just print the renames (without executing them). If the result is OK, remove the ‘-n‘ switch and execute the command again. Now the files will be renamed in order.

Update (20110130) #2:

This post was taken over by Ubuntu Life, and the user Capitán suggested an easier solution in a comment over there:


I didn’t know about this wget feature :) Now I see why issues < 10 are named as issueX_en.pdf and not as issue0X_en.pdf

Update (20110203): That {0..45} thing is actually expanded by bash, not by wget! See this post for more info.

Update (20110130) #3:

Another reader of Ubuntu Life, marco, suggests a bash script solution:

for i in {0..45}

Or, in one line:

for i in {0..45}; do wget${i}_en.pdf; done

Rename several files

November 4, 2010 Leave a comment


I have 12 files named as Scan10032.JPG, Scan10033.JPG, …, Scan10043.JPG. From their names I want to remove the “Scan” prefix and I want the extension in lowercase.


There is a very handy script for this called rename which is part of the standard installation. It’s actually a Perl script, written by Larry Wall himself. So:

rename -n 's/Scan(.*)\.JPG/$1.jpg/' *.JPG

First use the -n switch which means “No Action: show what files would have been renamed.” It means the files are not renamed and you have the chance to verify everything. If it’s OK, just remove the -n switch.

For more info refer to the man page. If you want more fancy renames, check out this post of mine where I use a simple Python script for a similar problem.

Categories: bash Tags: ,