The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
what is wrong with this tr -d? cleansing_flame UNIX for Dummies Questions & Answers 3 02-06-2008 09:34 AM
What’s wrong with the following? vrn UNIX for Dummies Questions & Answers 8 03-19-2006 06:09 PM
where have i gone wrong? Blip Shell Programming and Scripting 3 01-28-2004 01:43 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #8  
Old 06-19-2007
Registered User
 

Join Date: Jun 2007
Posts: 4
Well, I got it to work, but what's really weird was that what I ended up doing was copy/pasting what I had into a new "Test.sh" file and changing the paths to something else that existed but had no spaces. It took my like two minutes to get it to work. Then, when I copied and pasted the exact same paths into my old script, it gave the same error, even though the two were identical. So all I did was rename my test script and change the paths back, and it worked.

I must have had some whitespace character that was bad for UNIX or something.

Here's the final program.
Code:
# This shell script can be used to automatically place custom HoMM V
# maps into the proper directory. In order to use it, make sure you
# change the variable hommv_path to wherever it is on your hard drive,
# and change the copy_dir to wherever you want to copy the maps from.
# Then, simply double click to open this, all maps in the copy_dir will
# be copied into the maps folder for hommv_path.
#
# This script was made by Demonpants sixleg.com steal it if you want. :-)
#
hommv_path="/Applications/Games/Heroes of Might and Magic V.app/"
move_dir="/Users/eli/Desktop/"
maps_dir="Contents/Resources/transgaming/c_drive/Program Files/Ubisoft/Heroes of Might and Magic V/"
total_dir=$hommv_path$maps_dir
folder_name="Maps/"
#
#Creates the Maps directory if needed
if [ -d "$total_dir$folder_name" ];
	then
	echo "Maps folder found.";
else
	cd "$total_dir";
	mkdir "$folder_name";
	echo "New folder $folder_name created in $total_dir";
fi
#
#Moves all .h5m files from the move_dir to the Maps folder
cd "$move_dir"
for file in *.h5m;
	do
	mv "$file" "$total_dir$folder_name";
	echo "Map $file moved to $total_dir$folder_name";
done
#
echo "All maps moved successfully."
So thanks for all the help. Oh, and one thing that should be noted is that Mac OS X conventions that work within the Terminal do not work within shell scripts. The tilde, for example (~), is supposed to link to your home directory, and typing "\ " is supposed to represent a space no questions asked. This stuff doesn't work when running from a script (or a .command file, as I changed it to later).
Reply With Quote
Google The UNIX and Linux Forums
Forum Sponsor
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:19 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0