Forums » Off-Topic

Help me make a bash script!

«12
Oct 11, 2004 Pyro link
Tyrdium@hal /cygdrive/c/documents and settings/tyrdium/desktop/weapons2
$ ./test.sh
find: [a-z]: No such file or directory

If it helps:
Tyrdium@hal /cygdrive/c/documents and settings/tyrdium/desktop/weapons2
$ ls
ammo_and_mis......daggers.......great_swords..katana....scythes........swords
axes........................great_axes....hand-to-hand..polearms..sortedcrop.sh..test.sh
clubs.......................great_katana..instruments...ranged....staves

(I'm working on an item database for FF XI)
Oct 11, 2004 roguelazer link
You told me they were in directories called a b c d e f etc...
Oct 11, 2004 Pyro link
Well, yeah, I was using those as examples. I assume the script needs to be changed, then? Whoops... ~.~
Oct 11, 2004 roguelazer link
Do the subdirectories also have names? How about the numbered ones? Are they all single-digit or what?

Anyhow, try redownloading it. It might work now.
Oct 11, 2004 Pyro link
The ammo_and_mis has three subdirectories: ammunition, fishing_gear, and pet_items. Within each directory (the three under ammo_and_mis, and all the others) are directories labelled 3, 4, 5, 6, and 7 (not all main directories have all the numbered directories), which contain the images.

Edit: This one worked, but only in the ammo_and_mis directory, and I got lots of errors from mogrify trying to open all the various Thumbs.db files. Is there a way to get it to skip them?
Oct 11, 2004 roguelazer link
Depends. Are all of the files the same type (ie all bmp, all jpeg) ?
Oct 11, 2004 Pyro link
Yeah, they're all bitmaps.
Oct 11, 2004 roguelazer link
Try the newly updated version.
Oct 11, 2004 Pyro link
Normal version yields a bunch of cd errors, looks like it's trying /cygdrive/c/documents. Modified version with quotes around the "$(DIRECTORY)" (or whatever it is) yields a bunch of "find: [0-9]: No such file or directory". Both versions yield an "alias: not found" as the first error to show up.
Oct 12, 2004 roguelazer link
Try it again. And it's ${DIRECTORY}. That's how you encase variables in bash scripts.
Oct 12, 2004 Pyro link
Cool, I'll try it out when I get home (in school right now). I really ought to set up VNC and dyndns sometime...
Oct 12, 2004 Craigus Meridius link
<marque>I HATE code<marque/>
Oct 12, 2004 roguelazer link
Or at least a SSH server...
Oct 12, 2004 Pyro link
Yeah, except I'm running Windows, not Linux. As much as I love Linux, it's too much work... :P

Edit: Nope, still only works on ammo_and_mis, still gives me cd errors...
Oct 12, 2004 Pyro link
It works if I do this, but it runs very slowly and I get a bunch of:

DIRECTORY=swords: not found
cd: can't cd to
find: [0-9]: No such file or directory
cd: can't cd to /cygdrive/c/documents

---
Changes:

DIRECTORY=$i ------------> "DIRECTORY"=$i
cd ${DIRECTORY} ------------> cd "${DIRECTORY}"

Now then, is there an automated way to get the images out of the numbered directories and back into their parent directories (e.g., /staves/3/clp??.bmp -> /staves/clp??.bmp)? :P
Oct 12, 2004 roguelazer link
Um. You can't put quotes around a variable name when declaring it in bash. I think cygwin has a 3.x series bash available, you should download it. Because yours is obviously weirded up.
Oct 12, 2004 Pyro link
I dunno, I just installed it a few days ago...