Scripting help

Hello,

I have a batch script that I need to convert over to OS X. Any assistance is much appreciated.

Heres the file:

echo off
setlocal EnableDelayedExpansion
echo ***************MDF Creator 5.0 ***************
rem Written by Jaron Phillips 4.21.2015

:START
set StartingDir=%CD%
echo Your current Directory is %StartingDir%

:BROWSE
echo.
set /p Dir2Scan= Please enter a folder to scan:

:ORIGINALCOUNTS
rem this next line is used to get a string count for the current directory variable, it will be used later in the for loops to subtract that many characters from the root path
ECHO %CD%>x&FOR %%? IN (x) DO (SET /A strlength=%%~z? -3&del x)

for /F “delims=” %%B in ('dir “%Dir2Scan%” /B /A-D /S ^| find /c /v “.” ') do set /a Original_ALL_Count=%%B

for /F “delims=” %%B in ('dir “%CD%” /B /A-D /S ^| find /c “.mdf” ') do set /a Original_MDF_Count=%%B
echo.

echo Total files in %Dir2Scan%=%Original_ALL_Count%
echo Total MDF files in %CD%=%Original_MDF_Count%

set /a OriginalCount=%Original_ALL_Count%-%Original_MDF_Count%
echo There are %OriginalCount% files that need MDF files in in %Dir2Scan%.

echo.
echo MDF files will be created in %CD%

:CATEGORY
echo.
set /p Category=What Category will these Objects be archived with?:

:NAMEPREFIX
set /p NamePrefix=What Would you like to add as a prefix?:

:NAMEPREFIX
set /p Comments=Please put in any comments about this group of files:

:SCAN_PREFIX
set /A XCOUNT=0
echo.
echo Scanning Directory… this may take a few minutes

for /F “delims=” %%A in (‘dir %Dir2Scan% /b /s /A:-D ^| findstr /v “.mdf” ^| find /v “.”’) do (
echo # >> “%%~nxA.mdf”
echo # Object configuration >> “%%~nxA.mdf”
echo # >> “%%~nxA.mdf”
echo. >> “%%~nxA.mdf”
Set ERRORFILE=%%A
rem echo priority 50 >>“%%~nxA.mdf”
echo categoryName=%Category%>>“%%~nxA.mdf”
echo objectName=!random!!random!%NamePrefix%%%~nxA>>“%%~nxA.mdf”
echo. >> “%%~nxA.mdf”
echo ^<comments^> >>“%%~nxA.mdf”
echo %comments% >> “%%~nxA.mdf”
echo ^</comments^> >> “%%~nxA.mdf”
echo. >> “%%~nxA.mdf”
echo originalServer=%%~pA>>“%%~nxA.mdf”
rem echo originalPath=%%~pA>>“%%~nxA.mdf”
set chaine=%%~pA
set chaine=!chaine:~%strlength%!
rem echo sourceDestinationDIVAPath=!chaine! >>“%%~nxA.mdf”
echo. >> “%%~nxA.mdf”
echo ^<fileList^> >>“%%~nxA.mdf”
echo !chaine!%%~nxA >> “%%~nxA.mdf”
echo ^</fileList^> >> “%%~nxA.mdf”
rename “%%~nxA.mdf” “%%~nxA_!random!.mdf” >nul
IF !ERRORLEVEL! NEQ 0 goto :STOP
set /A XCOUNT=!XCOUNT!+1
echo !XCOUNT!/%OriginalCount% MDF Files Created %%~nxA.mdf
)
goto :SUMMARY

:SUMMARY
echo.
echo %XCOUNT% MDF files have been created in %CD%

echo this application will exit now
pause
goto :END

:STOP
echo.
echo *****************************
echo we have encountered an error
echo %ERRORFILE%
echo %ERRORLEVEL%
echo *****************************
pause

:END

It looks like it’s a script from a BAT file. I would suggest you try your luck on an shell/bash scripting forum instead of AppleScript. The similarities between Batch files and shell scripts is much more alike than AppleScript and Batch.