Renaming a bunch of files in Linux to make them contain SEO keywords
Some files are like
blah-815x338.png
blah2-300x800.png
blah--LIST-OF-KEYWORDS-815x338.png
blah2--LIST-OF-KEYWORDS-300x800.png
You can do that with
# rename -n 's/(-[0-9]*x[0-9]*\.[png,jpg,jpeg,gif])/--LIST-OF-KEYWORDS$1/' *
# rename -n 's/(-[0-9]*x[0-9]*\.[png,jpg,jpeg,gif])/--LIST-OF-KEYWORDS$1/' *
And some other files were like:
aaaaaa.jpg
eeeeeeee.png
whatever.gif
And we want them like
aaaaaa--LIST-OF-KEYWORDS.jpg
eeeeeeee--LIST-OF-KEYWORDS.png
whatever--LIST-OF-KEYWORDS.gifYou can do that with:
# find . | grep -v "LIST-OF-KEYWORDS" | cut -b 3- | while read file ; do echo $file;rename 's/(\.[png,jpg,jpeg,gif])/--LIST-OF-KEYWORDS$1/' "$file" ; done
# find . | grep -v "LIST-OF-KEYWORDS" | cut -b 3- | while read file ; do echo $file;rename 's/(\.[png,jpg,jpeg,gif])/--LIST-OF-KEYWORDS$1/' "$file" ; done
Hope it helps.
0 Comments:
Post a Comment
<< Home