|
|
|
bat file
|
|||
|---|---|---|---|
|
#18+
Мне нужно сделать бат файлик который бы вызывал утилиту из папки windows и обрабатывал все файлы с определенным расширением в текущей папке. Делаю примерно вот так: for %%x in (*.dat) do C:\Windows\util.exe %%x Но вопрос в том что util.exe сделана через одно место и я не могу им обрабатывать файлы с большими именами (>8 символов). Поэтому мне нужно переименовать все файлы в папке например в 1.dat , 2.dat etc... А после обработки переименовать обратно. Как это сделать? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 03.11.2009, 12:34:06 |
|
||
|
bat file
|
|||
|---|---|---|---|
|
#18+
Петров Андрей, Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. примерно так ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 03.11.2009, 12:48:30 |
|
||
|
bat file
|
|||
|---|---|---|---|
|
#18+
Ну получается примерно следующее: Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. Но по логу оно пчему то не присваивает вот тут set %NUM% = %2 правильное значение в переменную :-( Точнее присваивает пустоту. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 03.11.2009, 13:09:51 |
|
||
|
bat file
|
|||
|---|---|---|---|
|
#18+
Ошибка в том, что в команде SET не должно быть пробелов вокруг знака равенства, иначе будет восприниматься как присваивание пустого значения. Да и арифметические выражения нельзя было делать с переменными окружения в эпоху Windows NT (не знаю, как сейчас). В общем вот работающий пример. Я составил программу hello.exe, которая в диалоговом окне выводит командную строку (будем считать, что первый параметр): Код: plaintext 1. 2. 3. 4. 5. 6. 7. Код: plaintext 1. Код: plaintext 1. 2. 3. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 03.11.2009, 20:57:56 |
|
||
|
bat file
|
|||
|---|---|---|---|
|
#18+
Еще можно использовать короткие имена http://rsdn.ru/article/winshell/batanyca.xml http://sgw32.ucoz.ru/publ/4-1-0-1 ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 04.11.2009, 09:06:02 |
|
||
|
bat file
|
|||
|---|---|---|---|
|
#18+
VowkДа и арифметические выражения нельзя было делать с переменными окружения в эпоху Windows NT (не знаю, как сейчас). Можно . ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 04.11.2009, 09:10:44 |
|
||
|
bat file
|
|||
|---|---|---|---|
|
#18+
Mozok, спсб за сцылку, буду знать. Тогда приведенный пример можно переделать так, как было задумано вначале - последовательная нумерация временных файлов начиная с 1. Но все-таки тут больше вероятность совпадения имени временного файла с уже существующим. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 04.11.2009, 09:55:20 |
|
||
|
bat file
|
|||
|---|---|---|---|
|
#18+
belugin, посмотрел, спасибо. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 04.11.2009, 10:05:32 |
|
||
|
bat file
|
|||
|---|---|---|---|
|
#18+
А что за такая уникальная утилита бородатых времён? Неужели её нельзя подыскать современный аналог? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 04.11.2009, 11:16:47 |
|
||
|
bat file
|
|||
|---|---|---|---|
|
#18+
Спасибо - убрал пробелы но все равно не пашет. Вот кусок лога: Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. А вот кусок бат файла: Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 05.11.2009, 12:37:57 |
|
||
|
bat file
|
|||
|---|---|---|---|
|
#18+
Сделал использование коротких имен. Но теперь не могу переместить получившийся файл в новую папку с нормальным именем: Код: plaintext 1. 2. 3. Фактически здесь нужно взять 8.3 имя файла без расширения и добавить к нему .SQ Команда: %%~si.SQ не проходит к сожалению. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 05.11.2009, 13:07:10 |
|
||
|
bat file
|
|||
|---|---|---|---|
|
#18+
Петров Андрей, Код: plaintext 1. 2. 3. 4. 5. 6. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 05.11.2009, 14:19:03 |
|
||
|
bat file
|
|||
|---|---|---|---|
|
#18+
Спасибо - исправил. А как насчет отрезания расширения файла? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 05.11.2009, 15:07:36 |
|
||
|
bat file
|
|||
|---|---|---|---|
|
#18+
Петров АндрейСпасибо - исправил. А как насчет отрезания расширения файла? Можно выполнить move в какую-то временный каталог, затем сделать ren *.sql *.sq в этом каталоге, затем выполнить move из временного каталога в требуемый. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 05.11.2009, 17:15:16 |
|
||
|
bat file
|
|||
|---|---|---|---|
|
#18+
Петров Андрей, спасает Виндошная справка:) : Windows XP Help and SupportVariable substitution Substitution modifiers for for variable references have been enhanced. The following table lists optional syntax (for any variable I). Variable with modifier Description %~I Expands %I which removes any surrounding quotation marks (""). %~fI Expands %I to a fully qualified path name. %~dI Expands %I to a drive letter only. %~pI Expands %I to a path only. Код: plaintext %~sI Expands path to contain short names only. %~aI Expands %I to the file attributes of file. %~tI Expands %I to the date and time of file. %~zI Expands %I to the size of file. %~$PATH:I Searches the directories listed in the PATH environment variable and expands %I to the fully qualified name of the first one found. If the environment variable name is not defined or the file is not found by the search, this modifier expands to the empty string. The following table lists modifier combinations that you can use to get compound results. Variable with combined modifiers Description %~dpI Expands %I to a drive letter and path only. %~nxI Expands %I to a file name and extension only. %~fsI Expands %I to a full path name with short names only. %~dp$PATH:I Searches the directories listed in the PATH environment variable for %I and expands to the drive letter and path of the first one found. %~ftzaI Expands %I to an output line that is like dir. In the above examples, you can replace %I and PATH by other valid values. A valid for variable name terminates the %~ syntax. By use uppercase variable names such as %I, you can make your code more readable and avoid confusion with the modifiers, which are not case-sensitive. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 05.11.2009, 18:30:38 |
|
||
|
bat file
|
|||
|---|---|---|---|
|
#18+
MozokПетров Андрей, спасает Виндошная справка:) : Windows XP Help and SupportVariable substitution Substitution modifiers for for variable references have been enhanced. The following table lists optional syntax (for any variable I). Variable with modifier Description %~I Expands %I which removes any surrounding quotation marks (""). %~fI Expands %I to a fully qualified path name. %~dI Expands %I to a drive letter only. %~pI Expands %I to a path only. Код: plaintext %~sI Expands path to contain short names only. %~aI Expands %I to the file attributes of file. %~tI Expands %I to the date and time of file. %~zI Expands %I to the size of file. %~$PATH:I Searches the directories listed in the PATH environment variable and expands %I to the fully qualified name of the first one found. If the environment variable name is not defined or the file is not found by the search, this modifier expands to the empty string. The following table lists modifier combinations that you can use to get compound results. Variable with combined modifiers Description %~dpI Expands %I to a drive letter and path only. %~nxI Expands %I to a file name and extension only. %~fsI Expands %I to a full path name with short names only. %~dp$PATH:I Searches the directories listed in the PATH environment variable for %I and expands to the drive letter and path of the first one found. %~ftzaI Expands %I to an output line that is like dir. In the above examples, you can replace %I and PATH by other valid values. A valid for variable name terminates the %~ syntax. By use uppercase variable names such as %I, you can make your code more readable and avoid confusion with the modifiers, which are not case-sensitive. чтобы каждый раз не лезть в нелр и часто определить "короткое имя": -- CMDParams.cmd Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 05.11.2009, 23:35:38 |
|
||
|
bat file
|
|||
|---|---|---|---|
|
#18+
Итак вот что получаем в итоге: Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 12.11.2009, 17:45:25 |
|
||
|
bat file
|
|||
|---|---|---|---|
|
#18+
Петров Андрей, А чем плох такой вариант? Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 12.11.2009, 23:28:33 |
|
||
|
bat file
|
|||
|---|---|---|---|
|
#18+
Тем что 1) В программу передается имя из 8 символов (короткое) 2) тем что файлы надо класть в отдельную папку ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 13.11.2009, 11:59:17 |
|
||
|
bat file
|
|||
|---|---|---|---|
|
#18+
Петров Андрей, Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 13.11.2009, 17:42:18 |
|
||
|
|

start [/forum/topic.php?fid=16&fpage=114&tid=1344103]: |
0ms |
get settings: |
7ms |
get forum list: |
21ms |
check forum access: |
4ms |
check topic access: |
4ms |
track hit: |
90ms |
get topic data: |
12ms |
get forum data: |
3ms |
get page messages: |
72ms |
get tp. blocked users: |
2ms |
| others: | 207ms |
| total: | 422ms |

| 0 / 0 |
