Results 1 to 5 of 5
Hi,
I`m knew to this forum , hope you guys out there can find solutions to my Kubuntu setup.
The thread starter says mostly what I need but I`ll go ...
- 01-29-2012 #1Just Joined!
- Join Date
- Jan 2012
- Location
- Earth
- Posts
- 43
922 files need 0001 - taken out of the title; How ?
Hi,
I`m knew to this forum , hope you guys out there can find solutions to my Kubuntu setup.
The thread starter says mostly what I need but I`ll go into it abit more.
- 922 files - name examples :
- 0002 - Ticket to America1-001.mpg
- 0011 - Ticket to America2-014.mpg
- 0032 - Racing the Wind 1- 001.wmv
- 0054 - Racing the Wind 2- 008.wmv
OK. So , what I want to do is delete the "0002 -", part of the file name on all 922 files.
Yes, i could go through the archive and delete the parts one by one but I`d get tendonitis.
A solution would bring considerable brain relief.
Thanks.
- 01-29-2012 #2
Look into PERL
- 01-29-2012 #3Just Joined!
- Join Date
- Jan 2012
- Location
- Earth
- Posts
- 43
Ok, thanks , I`ve just looked at it but don`t see a solucion there. It`s not just a dozen or so files it`s a mega archive.
The "0001 , 0014, 0054" etc need removing , the rest of the name and ext stays the same.
- 01-30-2012 #4Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Hi.
The rename utility allows perl statements to be used to configure how the resulting filename should look. For example:
producing:Code:#!/usr/bin/env bash # @(#) s1 Demonstrate rename files with perl-pattern utility "rename". # Utility functions: print-as-echo, print-line-with-visual-space, debug. # export PATH="/usr/local/bin:/usr/bin:/bin" pe() { for _i;do printf "%s" "$_i";done; printf "\n"; } pl() { pe;pe "-----" ;pe "$*"; } db() { ( printf " db, ";for _i;do printf "%s" "$_i";done;printf "\n" ) >&2 ; } db() { : ; } C=$HOME/bin/context && [ -f $C ] && $C pl " Local file example set:" ls -lgG 0* pl " Results:" rename --no-act 's/^\d* - //' 0* exit 0
Things to note:Code:% ./s1 Environment: LC_ALL = C, LANG = C (Versions displayed with local utility "version") OS, ker|rel, machine: Linux, 2.6.26-2-amd64, x86_64 Distribution : Debian GNU/Linux 5.0.8 (lenny) GNU bash 3.2.39 ----- Local file example set: -rw-r----- 1 0 Jan 30 06:20 0002 - Ticket to America1-001.mpg -rw-r----- 1 0 Jan 30 06:20 0011 - Ticket to America2-014.mpg -rw-r----- 1 0 Jan 30 06:20 0032 - Racing the Wind 1- 001.wmv -rw-r----- 1 0 Jan 30 06:20 0054 - Racing the Wind 2- 008.wmv ----- Results: 0002 - Ticket to America1-001.mpg renamed as Ticket to America1-001.mpg 0011 - Ticket to America2-014.mpg renamed as Ticket to America2-014.mpg 0032 - Racing the Wind 1- 001.wmv renamed as Racing the Wind 1- 001.wmv 0054 - Racing the Wind 2- 008.wmv renamed as Racing the Wind 2- 008.wmv
1) "s'" means substitute: the part of the string to be deleted is "start-of-name digits space dash space"
2) the "--no-act" shows what will be done
See man rename for details ... cheers, drlWelcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )
- 01-30-2012 #5Just Joined!
- Join Date
- Jan 2012
- Location
- Earth
- Posts
- 43
Thanks for taking the time to post your cryptic answer. i have re-ordered all the files and put them in folders.
Thanks again for your solutions.


Reply With Quote