DOS Games Message Board
DOS Games Discussion
A message board to talk about DOS games, get help, and find old games.
Do NOT post warez or abandonware requests please
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Scripts and stuff

 
Post new topic   Reply to topic    DOS Games Discussion Forum Index -> Game Creation
Author Message
wardrich
"Some Troll"


Offline
Joined: 14 Sep 2002
Posts: 3942
Location: Ontario Canada

PostPosted: Wed Jun 13, 2007 6:26 pm     Post subject: Scripts and stuff Reply with quote

Since there are scattered posts all over the place about script files, I think it would be best to keep them all confined here from now on. Just to make it easier to follow it all. I'd split the other topics, but then all the posts and stuff would seem a bit out of place.
Back to top
wardrich
"Some Troll"


Offline
Joined: 14 Sep 2002
Posts: 3942
Location: Ontario Canada

PostPosted: Wed Jun 13, 2007 8:14 pm     Post subject: Reply with quote

I'm currently trying to work on one that looks at all the files in $PWD and sorts them into ./music/ and ./pictures/ folders depending on their filetypes... And since I'm lazy and don't usually add extensions to my image files, it makes my life that much more fun. lol

Code:

#/bin/bash
#Scattered Media Sorter Upper

if [ $(file "$i" | grep "image data") ]; then
   mv "$i" pictures
fi

if [ $(file "$i" | grep "Audio file") ]; then
   mv "$i" music
fi


I still have to add in the checks to see if ./music/ and ./pictures/ exists... and to make them if they don't.
Back to top
MiniMax
Expert
Expert


Offline
Joined: 25 Jan 2007
Posts: 149
Location: Stockholm, Sweden

PostPosted: Thu Jun 14, 2007 7:11 pm     Post subject: Reply with quote

That is some bad coding there. Better use a case-construct:

Code:
case "$(file "$i")" in

*"image data"* | *"bitmap data"* )
    mv "$i" pictures/
    ;;

*"Audio file"* )
    mv "$i" music/
    ;;

esac


Any fool can write code a computer can understand. It takes an expert to write code humans can understand
Back to top
wardrich
"Some Troll"


Offline
Joined: 14 Sep 2002
Posts: 3942
Location: Ontario Canada

PostPosted: Thu Jun 14, 2007 8:51 pm     Post subject: Reply with quote

Yeah, thanks MiniMax. My script still wasn't working, so I knew stuff had to be done. I'm a total newb to Bash scripts. Thanks for the help Happy.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    DOS Games Discussion Forum Index -> Game Creation All times are GMT - 5 Hours
Page 1 of 1

 
Free Windows games


Powered by phpBB © 2001, 2005 phpBB Group and Ask an Expert
Also powered by Darren and the other admin and mods' hard work! ;)