Re: renaming files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Thu, Mar 1, 2012 at 8:13 PM, pete <p.nikolic1@xxxxxxxxxxxxxx> wrote:
> I have some 350 picture files  with names  along the lines of
> "IMG_7127 EOS-1D Mark III copy.jpg"    i would like to rename them all
> to more like "IMG_7127.jpg"  i have tried a few times tonight and cant
> get my head around it anyone got a script that can do it

I like using vim for those tasks because of the interactivity (I fear
my dirty little scripts will go rogue and ruin all my files...)
Here's how it works:
$ ls | vim -
Then I get in vim one line per filename (unless there's a file with a
\n in its name, wich there never will be on my system!)
I use some vim commands to get something like (usualy something with
:%s/foo/bar)
...
mv "IMG_7127 EOS-1D Mark III copy.jpg" "IMG_7127.jpg"
mv "IMG_7128 EOS-1D Mark III copy.jpg" "IMG_7128.jpg"
...
Then I triple check if everything is OK (did I mention I'm paranoid?)
And finaly
:w !sh
To make vim execute the whole file as a sh script.
Done.


[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux