The gamer,the writer,the copy-paster,the blue-screen fighter,the auditor and the n00b. :)
A Sepuku Blade: A SHARP one! ^^
When someone uses a GNU/Linux distro or a Unix-Like OS, sooner or later, there comes the time in this man’s life to write some scripts to make his life easier. One of the basic scripts i always wanted is to have a script to rename multiple files in a directory. With a little googling i could find some, but everything was missing something. So to have a script according to your needs and demands you must write one yourself. The script is not something special, but i thought i should share it just in case anyone needs to get an idea how something like that is done. I chose Korn Shell because it’s the default shell on OpenBSD. ;)
Here’s the script:
#!/bin/ksh
# Rename script
echo ‘Enter path to rename files: ’ # where do the files to rename rest? ;)
read path
echo ‘What file extension you want to rename?’ # jpg,txt etc
read file_ext
echo ‘What format should the renamed files have?: ’ # vacations_2012
read ren_format
echo ‘Give a number to start numbering the files: ’
read i
for file in *.${file_ext}
do
((i+=1))
subname=”${ren_format}_${i}”
newfile=”${path}/${subname}.${file_ext}”
mv “$file” “$newfile”
done
# end of script
The script is tested under KSH and OpenBSD 5.1 beta and works like a charm. ;)
—current programming condition.
Just started studying common lisp and i really like what i’ve read so far.In contrast to scheme where most of the times you write everything you need,in common lisp you can you use some pre-written code too.I really like both dialects of course for different reasons…
It’s really fun to travel inside the parentheses… ;)
Has happened to me *numerous* times. xD