UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 3rd, 2012, 04:38 AM
shantiq shantiq is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 9 shantiq User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 26 m 40 sec
Reputation Power: 0
Send a message via Skype to shantiq
How to remove a section of text in all audio filenames in a folder?

how to remove a section of text in all audio filenames in a folder?

i made a slight mistake on a conversion script and ended up with this



img716.imageshack.us[forwardslashhere]img716[forwardslashhere]8973[forwardslashhere]acabi.png


sorry but a picture is clearer than text here



how can i remove the section ".flac}.shn.shn} " in all the files from the commandline?

Reply With Quote
  #2  
Old September 3rd, 2012, 05:32 AM
SimonJM SimonJM is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Mar 2006
Posts: 2,108 SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 1 Day 4 h 16 m 23 sec
Reputation Power: 1485
Not tested, so be warned!

Code:
for fn in $(ls -1 *.flac}.shn.shn}*)
do
  new=$(echo $fn | sed 's/.flac}.shn.shn}//')
  mv $fb $new
done
__________________
The moon on the one hand, the dawn on the other:
The moon is my sister, the dawn is my brother.
The moon on my left and the dawn on my right.
My brother, good morning: my sister, good night.
-- Hilaire Belloc

Reply With Quote
  #3  
Old September 3rd, 2012, 06:15 AM
shantiq shantiq is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 9 shantiq User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 26 m 40 sec
Reputation Power: 0
Send a message via Skype to shantiq
thank you for prompt reply

can't be far off it gives me this


Quote:
for fn in $(ls -1 *.flac}.shn.shn}*) > do > new=$(echo $fn | sed 's/.flac}.shn.shn}//') > mv $fb $new > done mv: missing destination file operand after `08.' Try `mv --help' for more information. mv: missing destination file operand after `Instante.shn' Try `mv --help' for more information.

Reply With Quote
  #4  
Old September 3rd, 2012, 03:32 PM
spacebar208's Avatar
spacebar208 spacebar208 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2012
Location: spaceBAR Central
Posts: 188 spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 9 h 9 m 4 sec
Reputation Power: 41
Try this and obviously like simonJM said it hasn't been tested:
Code:
for fn in `ls *.flac}.shn.shn}*`
do
  new_fn=`echo $fn | sed 's/.flac}.shn.shn}//'`
  echo "Current name: $fn"
  echo "New     name: $new_fn"
  mv $fn $new_fn
done
Comments on this post
SimonJM agrees: Gah, I typoed $fn to $fb!

Reply With Quote
  #5  
Old September 4th, 2012, 04:15 AM
shantiq shantiq is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 9 shantiq User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 26 m 40 sec
Reputation Power: 0
Send a message via Skype to shantiq
thank you spacebar

direct hit [ had tried to think of something in the way of fn_new]
but not enough to make it work: this is perfect thanx

Quote:
~/Desktop/Arrigo/5$ for fn in `ls *.flac}.shn.shn}*` > do > new_fn=`echo $fn | sed 's/.flac}.shn.shn}//'` > echo "Current name: $fn" > echo "New name: $new_fn" > mv $fn $new_fn > done Current name: 08.Instante.flac}.shn.shn}.shn New name: 08.Instante.shn





i forgot to mention something tho and that is that some of the files have gaps in them so those will not work with this....

Quote:
07. Clara Crocodilo.flac}.shn.shn.shn


if i use this first

Code:
for f in *.shn;  do rename 's/\ * /_/g'   "$f"  "${f%.*shn}.shn" ;done




all gaps are gone and then i can use the script; but then my cuefile no longer functions so i need to keep the original gaps in the songs titles and remove .flac}.shn.shn


anyone can see a clever way to add that functionality to the script? thanx in advance shan


Reply With Quote
  #6  
Old September 5th, 2012, 12:53 AM
spacebar208's Avatar
spacebar208 spacebar208 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2012
Location: spaceBAR Central
Posts: 188 spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 9 h 9 m 4 sec
Reputation Power: 41
Umm, I don't think that is the problem, the file name you denote as not being listed doesn't have a '}' after the 2nd "shn", look at my tests below for the 3 file names and the 'ls' command that will list them:

Code:
07. Clara Crocodilo.flac}.shn.shn}.shn
08.Instante.flac}.shn.shn}.shn
07. Clara Crocodilo.flac}.shn.shn.shn

$ ls *.flac}.shn.shn}* *.flac}.shn.shn.*
07. Clara Crocodilo.flac}.shn.shn.shn
07. Clara Crocodilo.flac}.shn.shn}.shn
08.Instante.flac}.shn.shn}.shn

Reply With Quote
  #7  
Old September 5th, 2012, 04:08 AM
shantiq shantiq is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 9 shantiq User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 26 m 40 sec
Reputation Power: 0
Send a message via Skype to shantiq
actually it does i simply did not copy it right

it should have read


Quote:
07. Clara Crocodilo.flac}.shn.shn}.shn



sorry i am really bad at copying code


your script works a charm when there are no gaps but on a different folder with same mistake this is what i get


Quote:
shantiq@shantiq-00000000000000000000000:/media/777a9ed8-803f-42d0-af07-c03b98c26ba2/Music/Jean Martinon (1989) Debussy Complete Orchestral Works III/Untitled Folder$ for fn in `ls *.m4a}*` > do > new_fn=`echo $fn | sed 's/.m4a}//'` > echo "Current name: $fn" > echo "New name: $new_fn" > mv $fn $new_fn > done Current name: 01 New name: 01 mv: cannot stat `01': No such file or directory Current name: - New name: - mv: cannot stat `-': No such file or directory Current name: Doctor New name: Doctor mv: cannot stat `Doctor': No such file or directory Current name: Gradus New name: Gradus mv: cannot stat `Gradus': No such file or directory Current name: and New name: and mv: cannot stat `and': No such file or directory Current name: Parnassum.m4a}.shn New name: Parnassum.shn mv: cannot stat `Parnassum.m4a}.shn': No such file or directory shantiq@shantiq-00000000000000000000000:/media/777a9ed8-803f-42d0-af07-c03b98c26ba2/Music/Jean Martinon (1989) Debussy Complete Orchestral Works III/Untitled Folder$



the original file is named and this time i make sure

Quote:
01 - Doctor Gradus and Parnassum.m4a}.shn



so there seems to be a gap issue

no big deal.... if you see it please tell me but no sweat...

thanx for your input


shan

Reply With Quote
  #8  
Old September 5th, 2012, 04:34 AM
SimonJM SimonJM is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Mar 2006
Posts: 2,108 SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 1 Day 4 h 16 m 23 sec
Reputation Power: 1485
Slightly different tack ..

Code:
ls -1 *.flac}.shn.shn}* > /tmp/shn.lst && while read fn
do
new=$(echo $fn | sed 's/.flac}.shn.shn}//')
echo Renaming "$fn" to "$new"
mv "$fn" "$new"
done < /tmp/shn.lst

Reply With Quote
  #9  
Old September 5th, 2012, 06:08 AM
shantiq shantiq is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 9 shantiq User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 26 m 40 sec
Reputation Power: 0
Send a message via Skype to shantiq
Quote:
Originally Posted by SimonJM
Slightly different tack ..

Code:
ls -1 *.flac}.shn.shn}* > /tmp/shn.lst && while read fn
do
new=$(echo $fn | sed 's/.flac}.shn.shn}//')
echo Renaming "$fn" to "$new"
mv "$fn" "$new"
done < /tmp/shn.lst



thank you Simon .... all gaps kept... excellent i am trying to learn from you guys


Code:
 01 - Doctor Gradus and Parnassum.m4a}.shn
[my other "mistake" in another folder] is now
Code:
01 - Doctor Gradus and Parnassum.shn



was also wondering [and will have a tinker] if there might be a route with rename [in Ubuntu and no doubt elsewhere... on the net under rename by Larry Wall]

see if that might also work

Quote:
RENAME(1) Perl Programmers Reference Guide RENAME(1) NAME rename - renames multiple files SYNOPSIS rename [ -v ] [ -n ] [ -f ] perlexpr [ files ] DESCRIPTION "rename" renames the filenames supplied according to the rule specified as the first argument. The perlexpr argument is a Perl expression which is expected to modify the $_ string in Perl for at least some of the filenames specified. If a given filename is not modified by the expression, it will not be renamed. If no filenames are given on the command line, filenames will be read via standard input. For example, to rename all files matching "*.bak" to strip the extension, you might say rename 's/\.bak$//' *.bak To translate uppercase names to lower, you'd use rename 'y/A-Z/a-z/' *

Reply With Quote
  #10  
Old September 5th, 2012, 06:37 AM
SimonJM SimonJM is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Mar 2006
Posts: 2,108 SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 1 Day 4 h 16 m 23 sec
Reputation Power: 1485
Good luck.

I tend to try and keep with 'standard' *nix tools as much as I can (experience of having to do things in HP-UX, Solaris, SuSE Linux, etc., etc.)

Reply With Quote
  #11  
Old September 5th, 2012, 01:21 PM
shantiq shantiq is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 9 shantiq User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 26 m 40 sec
Reputation Power: 0
Send a message via Skype to shantiq
ok and yes it works fine

rename is on my Ubuntu by default and can be found easily on the net under rename Larry Wall it is a Perl script


in this case
Code:
rename 's/.flac}.shn.shn}//'  *
worked fine too

One more tool I will keep with your scripts


Last edited by shantiq : September 5th, 2012 at 01:24 PM. Reason: correction

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > How to remove a section of text in all audio filenames in a folder?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap