You are not logged in.
hey all :>
i have several files which start with an URL in the file name such as www.foo.net_01.foo.jpg.
how can i remove the url in the beginning that i have a clean filename (foo.jpg)?
after some googling i found out that it's possible with find and sed but i have no clue how to exactly strip the file name with sed
thanks in advance and best regards :>
Offline
prename 's/^www\..+_(.+)$/$1/g' *.jpg
It'll croak on www.foo.com_file_name.jpg (you should provide real input and expected output)
Offline
#!/bin/bash
for file in *
do
newname1=${file##*_}
newname2=${newname1#*.}
# echo $file - $newname2
mv $file $newname2
done
Untested, so recommend running with mv line commented and echo line uncommented first.
If you have files in the dir that do not fit the name format, you may want to put in an if statement to ignore those - I use =~ and a regular expression.
Keeping it around as a script is probably a good idea.
Last edited by skanky (2010-07-26 10:00:33)
"...one cannot be angry when one looks at a penguin." - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle
Offline
For a graphical method try using gprename, its in the repos.
Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.
Offline
rename www.foo.net_01. '' www.foo.net_01.*
works as well.
(obviously only if they all start with the same url)
Last edited by splittercode (2010-07-26 10:12:52)
Offline