home *** CD-ROM | disk | FTP | other *** search
- @echo off
- echo ┌───────────────────────────────────────────────┐
- echo │ Convert Unix eolns of a text file to PC eolns │
- echo │ preserving the original date/time stamp │
- echo │ By Prof. Timo Salmi Wed 16-Oct-1991 │
- echo └───────────────────────────────────────────────┘
- echo.
-
- rem Skip tests as redundant if called from UNZIP since the tests are there
- if "%_checked%"=="yes" goto _unix2pc
-
- rem Give usage if necessary
- if "%1"=="" goto _noname
-
- rem Check that the file exists
- if not exist %1 goto _notfound
-
- rem Check that the needed drive exists
- if not exist r:\nul goto _no_r
-
- rem Check that unix2pc.exe is available (rem the test to speed up the bacth)
- set _found=
- if exist unix2pc.exe set _found=yes
- for %%d in (%path%) do if exist %%d\unix2pc.exe set _found=yes
- if not "%_found%"=="yes" goto _no_unix2pc
-
- rem Check that touch.exe is available (rem the test to speed up the bacth)
- set _found=
- if exist touch.exe set _found=yes
- for %%d in (%path%) do if exist %%d\touch.exe set _found=yes
- if not "%_found%"=="yes" goto _no_touch
-
- rem Check that the original Unix file is an ordinary text file
- :_unix2pc
- unix2pc /t < %1
- if errorlevel==1 goto _not_text
-
- rem --- Make a temporary directory ---
- mkdir r:\tmpu$$$
- rem --- Convert the eolns and put the result in a temporary file ---
- unix2pc < %1 > r:\tmpu$$$\tmp$$$
- rem --- Equate the date/time stamp of the temporary file with the original's
- touch /n r:\tmpu$$$\tmp$$$ /f%1
- rem --- Copy the temporary file back to the original ---
- echo on
- copy r:\tmpu$$$\tmp$$$ %1
- @echo off
- rem --- Delete the temporary file and directory ---
- del r:\tmpu$$$\tmp$$$ > nul
- rmdir r:\tmpu$$$
- rem --- Show the result ---
- dir %1
- goto :_out
-
- :_noname
- echo ╔══════════════════════╗
- echo ║ Usage: U2PC FileName ║
- echo ╚══════════════════════╝ ╒══════════════════════════════════╕
- echo │ At least DOS version 3.30 needed │
- echo ┌──────────────────────┐ ╘══════════════════════════════════╛
- echo │ Do not use wildcards │
- echo └──────────────────────┘
- echo.
- echo For multiple conversion of e.g. *.txt files use:
- echo for &f in (*.txt) do call u2pc &f (where & means the percent sign)
- goto _out
-
- :_notfound
- echo File %1 not found
- goto _out
-
- :_no_r
- echo You need to have directory R:\ available, or you have to adjust r:\
- echo in the batch as befits your own configuration.
- goto _out
-
- :_no_unix2pc
- echo UNIX2PC.EXE must be at the present directory or at path.
- echo UNIX2PC is a part of my TSFILT collection.
- goto _out
-
- :_no_touch
- echo TOUCH.EXE must be at the present directory or at path.
- echo TOUCH is a part of my TSUTLB collection.
- goto _out
-
- :_not_text
- echo File %1 is not an ordinary ascii text file
- echo The conversion not made
- goto _out
-
- :_out
- set _found=
- echo on
-