DevTricks

Удаление текста из файла

Jul 29th, 2021 (edited)
403
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. FileSelectFile, SelectedFile, 3, %scriptdir%,Открыть файл, Текстовые файлы (*.txt)
  2.     if SelectedFile =
  3.         return
  4. SplitPath, SelectedFile , , dir, ext, name_no_ext ;Парсинг полного пути к файлу
  5. Postfix:= _edit
  6. ;MsgBox, %dir%\%name_no_ext%_edit.%Ext%
  7. FileRead, Text, %SelectedFile%
  8. if not ErrorLevel ; Загрузка успешна.
  9. {
  10.     MsgBox, 3, Сохранение файла, Заменить исходный файл? (Нет - создать новый)
  11.         IfMsgBox Yes
  12.     {
  13.             FileDelete, %SelectedFile% ;Действие да
  14.             if ErrorLevel
  15.                 MsgBox, Ошибка перезаписи файла
  16.     }
  17.         Else IfMsgBox No
  18.     {
  19.             StringReplace, name_no_ext, name_no_ext, %name_no_ext%, %name_no_ext%_edit ;Действие нет
  20.             FileDelete, %dir%\%name_no_ext%.%Ext%
  21.     }
  22.         Else IfMsgBox Cancel
  23.     {
  24.             return ;Действие отмена
  25.     }
  26.     Text:= % RegExReplace(Text, "Checkmark", " ")
  27.     Text:= % RegExReplace(Text, "tgh", " ")
  28.     FileAppend, %Text% , %dir%\%name_no_ext%.%Ext%
  29. }
  30. else
  31.     MsgBox, Ошибка открытия файла
Add Comment
Please, Sign In to add comment