my ideas in action

loop all files inside a folder

Another command line trick.

Let’s say that you just come back from vacation and you have few hundreds pictures in a folder. And you want to rename them from DSCxxxxx.JPG to something else like Vacation_2012_xxx.JPG.

You can do this with just a single line command:

for file in DSC*; do mv “$file” Vacation_2012_”${file#DSC}”; done

So basically this command is taking all files from current folder, that start with DSC string. If your files start with different string the replace DSC with yours (example “IMG”…).

Then each file is renamed (mv command) in to Vacation_2012_xxxxx.JPG . As you can see the string replacement is just adding the “Vacation_2012_” to a string from which it deleted “DSC”.


Now lets say that you have somewhere a web photo album ( like a PHP or Picasa, or similar). You want to upload all pictures there but they are too big (12MP, or 16MP). Well, a similar strategy works here, like this command:

for file in *.JPG; do convert $file -resize 1000 $file; done

So the same looping in the current folder, but now the “convert” command is used and all pictures are re-sized to  1000 pixel width. Please run this on a backup , since the originals will be replaced !

for more option please use :

man convert



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: