I have gotten myself totally lost trying to sort this out and just need some help please..
I will have a multiple directories using the following naming convention with an undetermined number of files in each directory.
9780743582094_05of5_Accountable.wav
I need to batch rename all files grabbing the two digit number after the first underscore, and appending it to the end of the file name,with a preceding hyphen, before the extension.
The example: 9780743582094_05of5_Accountable.wav
Would become
9780743582094_05of5_Accountable-05.wav
I know sed or awk could work but I have not been using Linux/Unix for some time and really have burned out trying to remember this. Please show me the way with an explanation. I am using Ubuntu 10.04 and have the rename command available to me.
For those who are going to insist to see some effort on my part, sadly this is all I've got:
The reason i am doing this is to try and use a script that I found to batch convert wav files to .m4b audiobook format, but I first must convert to mp3. If anyone has a better suggestion to accomplish this, I would also love to hear about that. But first, I really need an answer to this sed issue because it is upsetting me.
Hi it is faster than awk or sed since no external programs need to be called from the shell to do the parsing..
for i in *_*_*.wav
for every file in the directory with this pattern
t=${i#*_}
remove the part before the first _ and put the remainder in variable t
mv "$i" "${i%.*}-${t%%of*}.${i##*.}"
mv file "$i" to the part of $i upto the extension (the last dot), followed by a "-" and variable $t with the part "of" and further cut off (which leaves the sequence number), then a dot (.) and then the extension of variable $i (everything before the last dot cut off)
I hope this helps. It can look a bit cryptic at first, but it really isn't that complicated..
Since $i will always contain files ending in .wav, this is equivalent in this case:
Last edited by Scrutinizer; 10-18-2010 at 11:04 AM..
I have a file comp.pkglist which mention package version and release . In 'version change' and 'release change' line there are two versions 'old' and 'new' Version Change: --> Release Change: -->
cat comp.pkglist
Package list: nss-util-devel-3.28.4-1.el6_9.x86_64
Version Change: 3.28.4 -->... (1 Reply)
Sorry for the long/weird title but I'm stuck on a problem I have. I have this XML file:
</member>
<member>
<name>TransactionID</name>
<value><string>123456789123456</string></value>
</member>
<member>
<name>Number</name>
... (9 Replies)
Dear All,
Can anyone help to remove the , bewteen "" in a string by using sed or awk?
e.g.
input : 1,4,5,"abcdef","we,are,here",4,"help hep"
output:1,4,5,"abcdef","wearehere",4,"help hep"
Thanks,
Mimi (5 Replies)
here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb
cat dump.sql
INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
I have a filename like 1_DATE_3_4.5_888 and I want to modify the date field (ie the last 4 digits ) alone and remove the last field.
Old filename:1_DATE_3_4.5_888
Given date (for eg):120606259532
modified date:120606259899
new filename:1_<modified date>_3.4.5 (14 Replies)
Hi all,
I have a list that I would like to parse with awk/sed. The list is contains entries such as:
JournalTitle: Biochemistry
JournalTitle: Biochemistry and cell biology = Biochimie et biologie cellulaire
JournalTitle: Biochemistry and experimental biology
JournalTitle: Biochemistry and... (6 Replies)
1. The problem statement, all variables and given/known data:
Problem Statement for project:
When an account is created on the CS Unix network, a
public html directory is created in the account's home directory. A default web page is put into that directory.
Some users replace or... (13 Replies)
in shell scripting there is extensive usage of
i> regular expression
ii>sed
iii>awk
can anyone tell me the suitable contexts ...i mean which one is suitable for what kind of operation.
like the reg-exp and sed seems to be doing the same job..i.e pattern matching (1 Reply)
Hi!
I am writing a script handling downloading list of files and I have to check whether file is present locally and if not finished than continue downloading. To do so I have to compare sizes of remote file and local file.
To check remote file size I have to parse something like this:
... (2 Replies)
I would appreciate it if any one can guide me in using awk perhaps sed in extracting some values from a long string.
here is an example.
.......some lines here........
........ aaaa bbbb cccc ddddd eeeee fffff gggg (time:hhhh)........
......some lines here also..........
How can I extract... (2 Replies)