Linux

Linux: change a large number of file names, all at once

Tags:

How do I change a lot of file names all at once, and using the linux command line?  Look no further.  Let’s say you have a bunch of images in your current directory (let’s create them like so for testing purposes):

for x in {1..100}; do touch “image$x.gif”; done

Now that you have all 100 gif images files, just run the following command to change them to have the .jpg file extension:

for x in *.gif; do mv “$x” “${x%.gif}.jpg”; done

Search and Replace using the vi Editor

Tags:

 If you’re like me then you’re using the unix vi editor like an oxygen tank on mars. But seriously, I’ve always liked the search and replace feature from other graphical based text editors so it’s only fair that we learn how to use vi’s search and replace function. It’s extremely useful and easy once you get the hang of it.

:%s/old_string/new_string/g

Syndicate content