The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #8 (permalink)  
Old 02-16-2008
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798
Quote:
Originally Posted by Astrid View Post
$ ./img2iso.sh
#: bad interpreter: No such file or directory
Perhaps a dos2unix or something similiar in Mac.

For your original script

Code:
#!/bin/bash

# Set the video directory here
VIDEO_ROOT_DIRECTORY="/Users/astrid/NFS/scripts/img2iso/";

# Check if the directory exist or not
if [ -d "$VIDEO_ROOT_DIRECTORY" ]; then
  cd $VIDEO_ROOT_DIRECTORY
else
  print "ERROR: Unable to reach directory - or it does not exist!";
  exit 1
fi

for imgfile in $(find . -type f -iname "*.img")
do
  if [ ! -f ${imgfile%.img}.iso ] ; then
    mv ${imgfile} "${imgfile%.img}.iso"
    print "[${imgfile} -> ${imgfile%.img}.iso]"
  else
    mv ${imgfile} "${imgfile%.img}-1.iso"
    print "[${imgfile} -> ${imgfile%.img}-1.iso]"
done

exit 0

Not tested tho'.