[arch-general] renaming files
Hi folks Bit sort of off topic but hopefully ok 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 Thanks Pete . -- Linux 7-of-9 3.2.8-1-ARCH #1 SMP PREEMPT Mon Feb 27 21:51:46 CET 2012 x86_64 AMD Phenom(tm) 9600B Quad-Core Processor AuthenticAMD GNU/Linux
You don't need a script, you can do that with: rename "EOS-1D Mark III copy" "" *.jpg That removes "EOS-1D Mark III copy" from all files ending in .jpg, assuming they are all in one directory. Thanks, Jarek Sedlacek On Thu, Mar 1, 2012 at 6:13 PM, pete <p.nikolic1@btinternet.com> wrote:
Hi folks
Bit sort of off topic but hopefully ok
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
Thanks Pete .
-- Linux 7-of-9 3.2.8-1-ARCH #1 SMP PREEMPT Mon Feb 27 21:51:46 CET 2012 x86_64 AMD Phenom(tm) 9600B Quad-Core Processor AuthenticAMD GNU/Linux
On Thu, 1 Mar 2012 18:15:56 -0500 Jarek Sedlacek <JarekSedlacek@gmail.com> wrote:
rename "EOS-1D Mark III copy" "" *.jpg
That almost did it now got a space "IMG_7059 .jpg" before the extension on each file Must admit thanks folks talk about lightening response brilliant Pete . -- Linux 7-of-9 3.2.8-1-ARCH #1 SMP PREEMPT Mon Feb 27 21:51:46 CET 2012 x86_64 AMD Phenom(tm) 9600B Quad-Core Processor AuthenticAMD GNU/Linux
You can use the same strategy to get rid of that space: rename " " "" *.jpg Thanks, Jarek Sedlacek On Thu, Mar 1, 2012 at 6:25 PM, pete <p.nikolic1@btinternet.com> wrote:
On Thu, 1 Mar 2012 18:15:56 -0500 Jarek Sedlacek <JarekSedlacek@gmail.com> wrote:
rename "EOS-1D Mark III copy" "" *.jpg
That almost did it now got a space "IMG_7059 .jpg" before the extension on each file
Must admit thanks folks talk about lightening response brilliant
Pete .
-- Linux 7-of-9 3.2.8-1-ARCH #1 SMP PREEMPT Mon Feb 27 21:51:46 CET 2012 x86_64 AMD Phenom(tm) 9600B Quad-Core Processor AuthenticAMD GNU/Linux
On 02.03.2012 00:13, pete wrote:
Hi folks
Bit sort of off topic but hopefully ok
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
If the string is always the same use this: rename " EOS-1D Mark III copy" "" *.jpg If not: for file in *.jpg; do mv "$file" "$(echo "$file" | sed 's/regex here//')" done This won't be fast, but it gets the job done. -- Florian Pritz
On 02.03.2012 00:16, Florian Pritz wrote:
On 02.03.2012 00:13, pete wrote:
Hi folks
Bit sort of off topic but hopefully ok
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
If the string is always the same use this:
rename " EOS-1D Mark III copy" "" *.jpg
If not:
for file in *.jpg; do mv "$file" "$(echo "$file" | sed 's/regex here//')" done
This won't be fast, but it gets the job done.
Totally forgot about perl-rename there. perl-rename 's/regex here//' *.jpg -- Florian Pritz
On Fri, 02 Mar 2012 00:16:06 +0100 Florian Pritz <bluewind@xinu.at> wrote:
On 02.03.2012 00:13, pete wrote:
Hi folks
Bit sort of off topic but hopefully ok
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
If the string is always the same use this:
rename " EOS-1D Mark III copy" "" *.jpg
If not:
for file in *.jpg; do mv "$file" "$(echo "$file" | sed 's/regex here//')" done
This won't be fast, but it gets the job done.
Morning All Thanks for the scripts ect problem now solved and plenty of ideas stashed so that hopefully next time i dont need to holler for help . I maintain a web site for my local car club there is a large collection of photo's from the various events we do each year so it gets big and was in need of a bit of TLC .. Thanks Pete . -- Linux 7-of-9 3.2.8-1-ARCH #1 SMP PREEMPT Mon Feb 27 21:51:46 CET 2012 x86_64 AMD Phenom(tm) 9600B Quad-Core Processor AuthenticAMD GNU/Linux
On 01-03-2012 23:13, pete wrote:
Hi folks
Bit sort of off topic but hopefully ok
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
Thanks Pete .
Assuming you don't mind bash scripts, maybe something like: IF=$'\n? for file in *.jpg do mv "$file" "$(echo $file | cut -f1 -d\ )".jpg done -- Mauro Santos
On 01-03-2012 23:18, Mauro Santos wrote:
On 01-03-2012 23:13, pete wrote:
Hi folks
Bit sort of off topic but hopefully ok
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
Thanks Pete .
Assuming you don't mind bash scripts, maybe something like:
IF=$'\n? for file in *.jpg do mv "$file" "$(echo $file | cut -f1 -d\ )".jpg done
Should be: IFS=$'\n' ... a little late here, not making much sense now :/ -- Mauro Santos
On Thu, Mar 1, 2012 at 8:13 PM, pete <p.nikolic1@btinternet.com> 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.
On 03/01/2012 04:13 PM, pete wrote:
Hi folks
Bit sort of off topic but hopefully ok
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
Thanks Pete .
I just picked vim-renamer in the AUR because I got tired of the limitations of "rename." It opens up a browse-able buffer (like when you open a directory with vim). It's got a pretty clean interface and I haven't had any problems with it so far.
pete <p.nikolic1@btinternet.com> writes:
Hi folks
Bit sort of off topic but hopefully ok
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
Install `moreutils' from [community], and use `vidir'. Otherwise, if you use Emacs, then C-x C-q in dired does that in the Emacs way. -- Carl Lei (XeCycle) Department of Physics, Shanghai Jiao Tong University OpenPGP public key: 7795E591 Fingerprint: 1FB6 7F1F D45D F681 C845 27F7 8D71 8EC4 7795 E591
On Thu, Mar 01, 2012 at 11:13:03PM +0000, pete wrote:
Hi folks
Bit sort of off topic but hopefully ok
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
If you don't mind graphical tools, try metamorphose2, it's available in the aur, and is an extremely powerful renamer, and quite easy to use too. -- O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
*Küldés ideje:* Fri, 2 Mar 2012 12:28:46 +0530. /gt <codered12@gmail.com> írta:/
Hi folks
Bit sort of off topic but hopefully ok
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 If you don't mind graphical tools, try metamorphose2, it's available in
On Thu, Mar 01, 2012 at 11:13:03PM +0000, pete wrote: the aur, and is an extremely powerful renamer, and quite easy to use too.
And there's GPRename, too.
On 02/03/12 07:02, Pataricza Zsolt wrote:
*Küldés ideje:* Fri, 2 Mar 2012 12:28:46 +0530. /gt <codered12@gmail.com> írta:/
Hi folks
Bit sort of off topic but hopefully ok
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 If you don't mind graphical tools, try metamorphose2, it's available in
On Thu, Mar 01, 2012 at 11:13:03PM +0000, pete wrote: the aur, and is an extremely powerful renamer, and quite easy to use too.
And there's GPRename, too.
I've used batren in the past with great results. I couldn't find it in AUR so I've uploaded a PKGBUILD to it. Nice (but old) simple stuff. batren http://batren.sourceforge.net/cgi-bin/blis.cgi/Home AUR pkgbuild https://aur.archlinux.org/packages.php?ID=57220 Regards timttmy
Il 02 marzo 2012 00:13, pete <p.nikolic1@btinternet.com> ha scritto:
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
There have been lots of good suggestion. I put on the plate "detox": https://aur.archlinux.org/packages.php?ID=7130 Its purpose is eliminating from filenames charachters that make them difficult to work with, so it's also good for files *beginning* with a space, esoteric utf8 characters, escape codes, parentheses and whatever. It's kind of overkill for this, but it deserves to be mentioned :-) C
participants (11)
-
Corrado Primier
-
Florian Pritz
-
gt
-
Jarek Sedlacek
-
marshall
-
Matthew Monaco
-
Mauro Santos
-
Pataricza Zsolt
-
pete
-
Vitor Eiji Justus Sakaguti
-
XeCycle