home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / TEXT / UTILITY / TSFILT18.ZIP / U2PC.BAT < prev    next >
Encoding:
DOS Batch File  |  1991-10-16  |  2.8 KB  |  95 lines

  1. @echo off
  2. echo ┌───────────────────────────────────────────────┐
  3. echo │ Convert Unix eolns of a text file to PC eolns │
  4. echo │ preserving the original date/time stamp       │
  5. echo │ By Prof. Timo Salmi Wed 16-Oct-1991           │
  6. echo └───────────────────────────────────────────────┘
  7. echo.
  8.  
  9. rem Skip tests as redundant if called from UNZIP since the tests are there
  10. if "%_checked%"=="yes" goto _unix2pc
  11.  
  12. rem Give usage if necessary
  13. if "%1"=="" goto _noname
  14.  
  15. rem Check that the file exists
  16. if not exist %1 goto _notfound
  17.  
  18. rem Check that the needed drive exists 
  19. if not exist r:\nul goto _no_r
  20.  
  21. rem Check that unix2pc.exe is available (rem the test to speed up the bacth)
  22. set _found=
  23. if exist unix2pc.exe set _found=yes
  24. for %%d in (%path%) do if exist %%d\unix2pc.exe set _found=yes
  25. if not "%_found%"=="yes" goto _no_unix2pc
  26.  
  27. rem Check that touch.exe is available (rem the test to speed up the bacth)
  28. set _found=
  29. if exist touch.exe set _found=yes
  30. for %%d in (%path%) do if exist %%d\touch.exe set _found=yes
  31. if not "%_found%"=="yes" goto _no_touch
  32.  
  33. rem Check that the original Unix file is an ordinary text file
  34. :_unix2pc
  35. unix2pc /t < %1
  36. if errorlevel==1 goto _not_text
  37.  
  38. rem --- Make a temporary directory ---
  39. mkdir r:\tmpu$$$
  40. rem --- Convert the eolns and put the result in a temporary file ---
  41. unix2pc < %1 > r:\tmpu$$$\tmp$$$
  42. rem --- Equate the date/time stamp of the temporary file with the original's
  43. touch /n r:\tmpu$$$\tmp$$$ /f%1
  44. rem --- Copy the temporary file back to the original ---
  45. echo on
  46. copy r:\tmpu$$$\tmp$$$ %1
  47. @echo off
  48. rem --- Delete the temporary file and directory ---
  49. del r:\tmpu$$$\tmp$$$ > nul
  50. rmdir r:\tmpu$$$
  51. rem --- Show the result ---
  52. dir %1
  53. goto :_out
  54.  
  55. :_noname
  56. echo ╔══════════════════════╗
  57. echo ║ Usage: U2PC FileName ║
  58. echo ╚══════════════════════╝    ╒══════════════════════════════════╕
  59. echo                             │ At least DOS version 3.30 needed │
  60. echo ┌──────────────────────┐    ╘══════════════════════════════════╛
  61. echo │ Do not use wildcards │
  62. echo └──────────────────────┘
  63. echo.
  64. echo For multiple conversion of e.g. *.txt files use:
  65. echo  for &f in (*.txt) do call u2pc &f  (where & means the percent sign)
  66. goto _out
  67.  
  68. :_notfound
  69. echo File %1 not found
  70. goto _out
  71.  
  72. :_no_r
  73. echo You need to have directory R:\ available, or you have to adjust r:\
  74. echo in the batch as befits your own configuration.
  75. goto _out
  76.  
  77. :_no_unix2pc
  78. echo UNIX2PC.EXE must be at the present directory or at path.
  79. echo UNIX2PC is a part of my TSFILT collection.
  80. goto _out
  81.  
  82. :_no_touch
  83. echo TOUCH.EXE must be at the present directory or at path.
  84. echo TOUCH is a part of my TSUTLB collection.
  85. goto _out
  86.  
  87. :_not_text
  88. echo File %1 is not an ordinary ascii text file
  89. echo The conversion not made
  90. goto _out
  91.  
  92. :_out
  93. set _found=
  94. echo on
  95.