You are not logged in.
Pages: 1
I need to rename .jpg files so that they match their folder names. What is the easiest way to do this? I'm thinking a bash script would be the best way, but I can't for the life of me figure out how to us a directory name as a variable. Any help?
Sweet zombie jesus!
Offline
Try mmv in AUR.
If you take e.g. the structure:
$ find
.
./a
./a/p
$ mmv -v '*/*' '#1/#1_#2'
a/p -> a/a_p
Offline
If you want to store the name of the directory a file is in in a variable named foo, you could do this:
foo=basename $(dirname /path/to/file)
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
you can use test, see:
http://www.ibm.com/developerworks/libra … -test.html
to see if a file is a directory
you don't need to declare a type of a variable when you specify it's value in bash, if you perform a non-allowed operation on a variable of the wrong type later it will fail, otherwise bash doesn't care.
I think all in for your script is:
variables (see the bash manual)
echo (maybe?)
ls
io redirection (see the bash manual)
loops / conditional constructs (see the bash manual)
sed (maybe?)
for ls, echo read the man pages, for the rest you can read the man pages or read fancy html guides on the internet.
Offline
KRename is a good GUI for it... I use it to rename photos from my digital camera.
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
Pages: 1