You are not logged in.
Pages: 1
I have a bunch of files named:
F4199_Otomo.ini
F2991_Dragon3E_F.dll
F4200_Shinja.ini
etc.
(Installing Battle Realms on wine )
I want to get rid of the prefix. How can I do this with a bash script?
Madly in love with Arch64, Openbox, DotA, and of course... penguins!
Happy to help if you're not a Help Vampire. Use your wonderful resources like ArchWiki, Google, and our wonderful search page.
Offline
This should help you: http://cyborg.lug.md/?p=25
Offline
(EDIT: Ignore this entry, it's bad because of multiple underscore files. Don't use it. Doing this with mmv takes a lot of extra commands. Maybe mmv '?????_*' '#6' though, if the prefixes are all 5 characters.)
mmv '*_*' '#2'
Last edited by Procyon (2008-08-09 13:07:58)
Offline
Allen's link won't load for me, but this is how i'd do it:
http://wooledge.org:8000/BashFAQ#head-c … 682991cc58
for file in *
do
mv "$file" "${file%.*}"
done
Last edited by dyscoria (2008-08-09 11:22:06)
flack 2.0.6: menu-driven BASH script to easily tag FLAC files (AUR)
knock-once 1.2: BASH script to easily create/send one-time sequences for knockd (forum/AUR)
Offline
But then mv "$file" "${file#*_}", right?
Also for security add -b and -v to mv.
I think this is better than my approach because if there are two underscores then I don't really know what will happen, I think you'll end up with a file like F.dll instead of Dragon3E_F.dll
Offline
To remove the prefix, you need something like:
for FNAME in $(ls) ; do
mv $FNAME ${FNAME:6:999}
done
Test it first (replace 'mv' with 'echo')
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
That page was working earlier... From the google cache (http://209.85.141.104/search?q=cache:tM … =clnk&cd=1)
${param%word} - From the end, removes the smallest part of param that matches word and returns the rest.
${param%%word} - From the end, removes the longest part of param that matches word and returns the rest.
${param#word} - From the beginning, removes the smallest part of param that matches word and returns the rest.
${param##word} - From the beginning, removes the longest part of param that matches word and returns the rest.
Offline
To remove the prefix, you need something like:
for FNAME in $(ls) ; do mv $FNAME ${FNAME:6:999} done
Test it first (replace 'mv' with 'echo')
Quick and simple, thanks!
And thanks for all the help from everyone else as well. My shell scripting knowledge is increasing slowly.
Madly in love with Arch64, Openbox, DotA, and of course... penguins!
Happy to help if you're not a Help Vampire. Use your wonderful resources like ArchWiki, Google, and our wonderful search page.
Offline
Here' s how I would do it:
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMLLMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMML9H@^^&pPMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMML9HddH9MMMMMMMMME ^@W&^^EMMMMMMMMMMLMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM3 HLQ9HDMMMMMMM&^^@dH3&^^MMMMMMDN@@H_3MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM@^&PMMM_3MMMMMMD _@zMMQ_ LMMMW__pPMMW LMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM@ 7MMMMd zMMMMMd pLMMLz@HMMMP^^zMMMMW DMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM& dMMML_ @LMMMQ JLJ3_ ^dMMMN^&MMMMP EMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMD &MMML3^^PMMME _ &p9N& ^pMMM&^@MMMMD ^7MMMMMMMMMMMMMMMMMMMMMM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